camel_racer Posted July 13, 2010 Posted July 13, 2010 This is a pretty big ask, but i was wondering if anyone knew of a lisp program (or how to write one) that would generate a list of layers in a drawing by using selected block names. i.e. I select 2 blocks (called Block1 & Block2) and press a button & then 2 layers will be created with this name?.. If they could be moved onto the layer as well that would be useful. & my second (& probably even bigger) ask is would it be possible to create something that will put a number next to each line on a certain layer with its dimension in metres?... i.e. if i have a 3m x 3m square drawn on "Layer1", i then press a button & it will put the number "3" on the outside of each line on the sqaure. Both big asks but any help (or nudge in the right direction) would be greatly appreciated. Quote
Tharwat Posted July 13, 2010 Posted July 13, 2010 Hi This Lisp will take the name of the selected Block and create a Layer holding the Block's Name Block Layer would be Current , Continuous and Red Color . (defun c:blk (/ Ent BlkEnt blkNme ) (setq Ent (car(entsel "\n Select a Block: ")) BlkEnt (entget Ent) BlkNme (cdr (assoc 2 BlkEnt)) ) (vl-cmdf "_.-layer" "_m" BlkNme "ltype" "continuous" "" "color" "red" "" "") (setvar "clayer" BlkNme) (princ) ) Regards. Tharwat Quote
camel_racer Posted July 13, 2010 Author Posted July 13, 2010 Great!.. thanks! Is there a way to make it so I can group select a few blocks? Quote
Lee Mac Posted July 13, 2010 Posted July 13, 2010 This should be a lot faster: (defun c:Blk2lay ( / ss ) ;; © Lee Mac 2010 (if (setq ss (ssget '((0 . "INSERT")))) ( (lambda ( i / e done ) (while (setq e (ssname ss (setq i (1+ i)))) (if (not (member (cdr (assoc 2 (entget e))) done)) (progn (entmake (list (cons 0 "LAYER") (cons 100 "AcDbSymbolTableRecord") (cons 100 "AcDbLayerTableRecord") (assoc 2 (entget e)) (cons 70 0) ) ) (setq done (cons (cdr (assoc 2 (entget e))) done)) ) ) (entupd (cdr (assoc -1 (entmod (subst (cons 8 (cdr (assoc 2 (entget e)))) (assoc 8 (entget e)) (entget e) ) ) ) ) ) ) ) -1 ) ) (princ) ) Quote
camel_racer Posted July 13, 2010 Author Posted July 13, 2010 That is awesome!... Works a treat!.. Thanks guys! Quote
alanjt Posted July 14, 2010 Posted July 14, 2010 HiThis Lisp will take the name of the selected Block and create a Layer holding the Block's Name Block Layer would be Current , Continuous and Red Color . (defun c:blk (/ Ent BlkEnt blkNme ) (setq Ent (car(entsel "\n Select a Block: ")) BlkEnt (entget Ent) BlkNme (cdr (assoc 2 BlkEnt)) ) (vl-cmdf "_.-layer" "_m" BlkNme "ltype" "continuous" "" "color" "red" "" "") (setvar "clayer" BlkNme) (princ) ) Regards. Tharwat FYI, when you use the MAKE option with Layer, the created layer will be set as current. No need to worry with setting clayer variable. Quote
BIGAL Posted July 14, 2010 Posted July 14, 2010 The auto dimensioning of lines or plines is pretty easy just a case of making a list of the lines and getting their length and putting text at the mid point. Hard part is getting text the correct side of the lines you may need a yes no for each. Heres an old one but a good starting point gives you most of the answers to create your own. ;SETOUT3.LSP ; program to draw setout details as a co-ord list ; with co-ords to two points ; 29/7/01 by alan (setvar "menuecho" 0) (setvar "SNAPMODE" 0) (COMMAND "STYLE" "MYDEFAULT" "ISO3098b" 0.0 1.0 0.0 "N" "N" "N") (setq oldangbase (getvar "angbase")) (setq oldangdir (getvar "angdir")) (setq oldaunits (getvar "aunits")) (setvar "angbase" 0.0) (setvar "angdir" 0) (setvar "aunits" 3) (SETQ SETSC (GETREAL "\nWhat is overall scale 1 ? ")) (SETQ TXTHT (* 1.75 setsc)) ;CHANGE TO ASK FOR FINAL PLOT SCALE (while (SETVAR "OSMODE" 1) (setq pt1 (getpoint "\nPick 1st point, press <cr> to exit")) (setq pt2 (getpoint "\nPick next point, press <cr> to exit")) (SETQ DIST (DISTANCE PT1 PT2)) (SETQ DISTMID (/ DIST 2.0)) (SETQ ANG (ANGLE PT1 PT2)) (setq pt3 (polar pt1 ANG DISTMID)) (setq pt3 (polar pt3 (+ ang 1.5707) 1.5)) (SETQ BLOCKLEN (RTOS DIST 2 2)) (SETVAR "OSMODE" 0) (command "text" "MC" pt3 txtht ANG BLOCKLEN) (setq flip (getstring "\nFlip text 180 press f ")) (if (or (= flip "f")(= flip "F")) (command "rotate" "l" "" pt3 3.14159) ) ) ; end while (setvar "angbase" oldangbase ) (setvar "angdir" oldangdir) (setvar "aunits" oldaunits) (setq pt1 nil pt2 nil pt3 nil pt4 nil pt5 nil pt6 nil stpt nil ans nil ) (princ) Therse another post today also about text to lines. Quote
camel_racer Posted July 14, 2010 Author Posted July 14, 2010 Thanks for that Bigal... That should be enough for me to butcher Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.