What I am looking for is a way to delete a named block out of the current (active) layout, then insert in a titleblock template. I run into a problem when the code finds a block with the same name on a different (non-active) layout. It just seems to quit on me.
I currently use the following lisp to delete and purge a block from my active layout:
(defun c:deleteblockNAME (/ ss)
(setq ss (ssget "_X" '((-4 . "<and")
(0 . "insert")
(2 . "NAME")
(-4 . "and>")
)
)
)
(command "erase" ss "")
(command "purge" "b" "NAME" "N")
)
I then have a macro to run that lisp along with more commands to insert in a new template:
deleteblockNAME;^C^C^P_-insert;NAME.dwg;0,0;1;;;_explode;_l;_limits;0,0;(list (* (getvar "dimscale") 1189) (* (getvar "dimscale") 841))^P
^C^C'_.zoom _e;
Everything works fine if I only have one layout tab, but if I create a new layout and run my macro, it just stops before the insert command. It gives me the following response if I look at my text window:
Command: deleteblockNAME
erase
Select objects: 1 found
1 was not in current space.
So it sees that I have a block with the same name in a different layout and just quits. How do I tell it to ignore it or force it to continue? I am frustrated because I can set up two seperate macros (each with their own toolbar button) and run them in succession and they work fine, but as soon as I combine them, it just stops.
HELP!!!
First I would change the ssget to only grab the insert block in the current layout:
(setq ss (ssget "_X" (list (cons -4 "<and")(cons 0 "INSERT")(cons 2 "ELEVINT")(cons 410 (getvar 'ctab))(cons -4 "and>"))))
Since the insert block may be in another layouts, the Purge command sequence would fail. I would remove this line from the code:
(command "purge" "b" "NAME" "N")
Then this diesel string should execute:
^C^C^P_-insert;NAME.dwg;0,0;1;;;_explode;_l;_limits;0,0;(list (* (getvar "dimscale") 1189) (* (getvar "dimscale") 841))^P
^C^C'_.zoom _e;
Area Object Link | Dwg Setup | Feet-Inch Calculator | List on Steroids
Exchange App Store