TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: TJAM51 on March 25, 2005, 10:38:23 AM

Title: Redefining blocks through lisp
Post by: TJAM51 on March 25, 2005, 10:38:23 AM
We receive drawings from our client. All equipment and fixtures are on the same layer. The client will not change his layer setup. What I am seeking is this......have the identified blocks that require certain utilities such as electrical redefined to a specific color sitting in a directory. When we receive the new background updates we run this routine and it brings the redefined blocks in from the specified directory and redefines them in the new drawing just received from our client....any chance?

Thanks
Title: Redefining blocks through lisp
Post by: CAB on March 25, 2005, 10:55:40 AM
http://www.theswamp.org/phpBB2/viewtopic.php?t=2272&highlight=block+replace
Title: Redefining blocks through lisp
Post by: TJAM51 on March 25, 2005, 11:07:39 AM
What I need if possible is that the blocks cannot be selected within the drawing. The routine needs to actually "reach" out to a directory with the modified blocks and bring them back into the parent drawing and redefine the old blocks leaving them on the same location and insertion point.  The blocks in the directory and in the parent drawing have the same name. For example 1=1, 2=2, 3=3, and so on.......
Title: Redefining blocks through lisp
Post by: CAB on March 25, 2005, 11:23:13 AM
http://www.theswamp.org/phpBB2/viewtopic.php?t=977&highlight=block+replace
Title: Redefining blocks through lisp
Post by: TJAM51 on March 25, 2005, 11:26:24 AM
Here is the code on the earlier posted message...


(command "-insert" "titleblock=c:/blks/titleblocks/titleblock")
(command)



How can this be modified to include more blocks such as 10 or 15 blocks........thanks for the assist
Title: Redefining blocks through lisp
Post by: CAB on March 25, 2005, 11:32:57 AM
So you see it can be done with the = in the Insert command

Code: [Select]
Pseudo Code
o  Get all blocks in the drawing [not Inserts]
o  Loop through the list of blocks
o  If the block exist in the directory
o    replace it in the drawing
o      (command "-insert" "blockname=c:/path/blockname")
o  Done
Title: Redefining blocks through lisp
Post by: TJAM51 on March 25, 2005, 11:39:50 AM
I have tried the routine but it failed somehow. Here is the code within a toolbar button with the block name.

(command "-insert" "lf033j=c:/blks/lf033j/lf033j")(command)


For the rest

Pseudo Code
o  Get all blocks in the drawing [not Inserts]
o  Loop through the list of blocks
o  If the block exist in the directory
o    replace it in the drawing
o      (command "-insert" "blockname=c:/path/blockname")
o  Done



I am not sure how to retrieve the blocks in the drawing...sorry my lisp expertise is not all that great.