TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: TJAM51 on June 23, 2005, 10:11:08 AM
-
We receive drawings from out client. These blocks are on the same layer. There are approximately 40 or so blocks total. Now each block has to be on a separate layer for out company to use in our MEP drawings. I am seeking a method of selecting all these blocks (remember theyall have separate names and each one needs to be on it's own layer) and placing them on their own specific layers. This needs to be done in one step or one run of a routine. Routines like "Get" as described in other discussions on this forum do not work due to the operator picking each block name separately. Any suggestions or ideas...thanks
-
what does the layer name have to be? could the layername be the same as the block name? if so, that would be very easy
-
The system seems to be kicking me out.......the layer names cannot match the block name. This is a decision made by higher ups. If someone could show me how to start the routine......show me next how to select the block and then place it on it's specified layer I could type in the rest.
Thanks
-
(setq ss (ssget "x" '((0 . "INSERT"))))
that'll start you. If you want to name specific blocks use '((2 . "blocknamehere"))
-
If I wanted to change the actual block to another layer how would that be stated?
-
This doesn't do the actual layer decision making, but it shows how you'd modify the block's layer.
(if (setq ss (ssget "x" '((0 . "INSERT"))))
(progn
(setq idx -1)
(while (< (setq idx (1+ idx))(sslength ss))
(setq ent (entget (ssname ss idx))
bname (cdr (assoc 2 ent))
ent (subst (cons 8 "whatever the layer should be here") (assoc 8 ent) ent)
)
(entmod ent)
)
)
)
-
If I wanted to change the actual block to another layer how would that be stated?
Like that^. :lol: Good work Jeff.
-
ANOTHER APPROACH..........I have created a menu button with the following script...........
-LAYER;M;E-LITA;C;30;;;^C^CSSX;;BLOCK;TYPE_300;;^C^CCHANGE;PREVIOUS;;P;LA;E-LITA;;
This button only deals with converting one block to one layer. I need to include numerous more blocks for this layer. How can this be written to include 17 more blocks?
-
Use Jeff's.
Change this line:
(if (setq ss (ssget "x" '((0 . "INSERT"))))
to
(if (setq ss (ssget "x" '(((-4 . "<OR") (2 . "blockname") (2 . "nextblockname_etc") (-4 . "OR>"))))
-
Ok...ltes see if I am heading in the right direction.....
(DEFUN C:GENERAL)
(command "LAYER" "M" "E-LITG" "C" "30" "" ""
"LAYER" "M" "E-LITA" "C" "30" "" "")
(if (setq ss (ssget "x" '(((-4 . "<OR") (2 . "TYPE_110")
(2 . "TYPE_122") (2. "type_120") (-4 . "OR>"))))
(PRINC)
I would continue to add the remaining block names as shown above, right? I receive the error messagen "SYNTAX ERROR".
-
try this one;
(DEFUN C:GENERAL (/ ss)
(command "LAYER" "M" "E-LITG" "C" "30" "" "")
(command "LAYER" "M" "E-LITA" "C" "30" "" "")
(if
(setq ss
(ssget "x"
'(
(-4 . "<OR")
(2 . "TYPE_110")
(2 . "TYPE_122")
(2 . "type_120")
(-4 . "OR>")
)
)
)
(princ (strcat "\nFound " (itoa (sslength ss)) " blocks"))
)
(PRINC)
)
-
Here is the final routine for the layer E-LITG.....
(DEFUN C:litg (/ ss)
(command "LAYER" "M" "E-LITG" "C" "30" "" "")
(if
(setq ss
(ssget "x"
'(
(-4 . "<OR")
(2 . "TYPE_110")
(2 . "TYPE_122")
(2 . "type_120")
(2 . "TYPE_125")
(2 . "TYPE_112")
(2 . "type_130-4")
(2 . "type_130-8")
(2 . "type_131-4")
(2 . "type_131-8")
(2 . "type_163")
(2 . "type_180-8")
(2 . "type_184")
(2 . "type_128")
(2 . "type_366")
(2 . "type_495")
(2 . "type_393")
(2 . "type_498")
(2 . "type_498e")
(-4 . "OR>")
)
)
)
(princ (strcat "\nFound " (itoa (sslength ss)) " blocks"))
)
(PRINC)
)
The only problem is that it will not affect any blocks from TYPE_120 on down. They remain on the same layer and color.....did I type something wrong?
Thanks
-
What you have looks right but you're not doing anything to the blocks in the selection set (ss). Now you have to iterate through the selection set and modify the blocks.
BTW have you tried "Quick Select"
http://www.theswamp.org/screens/mark/screen_shots/quick_select_blkname.png
-
Yes I have but attempting to eliminate as many steps as possible....
-
Here's another way of doing the same thing:
(DEFUN C:litg (/ ss)
(command "LAYER" "M" "E-LITG" "C" "30" "" "")
(if
(setq ss
(ssget "x"
'((2 . "TYPE_110,TYPE_122,type_120,TYPE_125,TYPE_112,type_130-4,type_130-8,type_131-4,type_131-8,type_163,type_180-8,type_184,type_128,type_366,type_495,type_393,type_498,type_498e"))
)
)
(progn
(princ (strcat "\nFound " (itoa (sslength ss)) " blocks"))
(command ".chprop" ss "" "la" "E-LITG" "")
)
)
(PRINC)
)
-
That is strange...this routine you added works great.....who can figure.....thanks
-
(DEFUN C:GENERAL (/ ss)
(command "LAYER" "M" "E-LITG" "C" "30" "" "")
(command "LAYER" "M" "E-LITA" "C" "30" "" "")
(if
(setq ss
(ssget "x"
'(
(-4 . "<OR")
(2 . "TYPE_110")
(2 . "TYPE_122")
(2 . "type_120")
(-4 . "OR>")
)
)
)
(progn
(setq cntr 0)
(while (setq ent (ssname ss cntr))
(setq entlst (entget ent))
(setq entlst
(subst
(cons 8 "0") ; change layer name here
(assoc 8 entlst)
entlst
)
)
(entmod entlst)
(setq cntr (1+ cntr))
)
)
)
(PRINC)
)