View Full Version : interaction with Block dialog box
rklee
2009-07-13, 09:10 PM
The users here need some help remembering to set layer 0 current when they issue the block command. I am trying to redefine the block command to first get the current layer, then set layer 0 current, issue the standard block command with the dialog, then when that is done restore the layer to what was current first. I can get it all to work except restoring the old layer. Any suggestions?
(command "undefine" "block")
(defun c:block ()
(setq curlayer (getvar "clayer"))
(command "layer" "set" "0" "")
(initdia)
(command ".block")
(command "layer" "set" curlayer)
)
rkmcswain
2009-07-13, 09:37 PM
How about this?
(command "undefine" "block")
(defun c:block ( / clayer)
(setq clayer (getvar "clayer"))
(setvar "clayer" "0")
(initdia)
(command ".block")
(while (eq 1 (logand (getvar "CMDACTIVE") 1))
(command PAUSE)
)
(setvar "clayer" clayer)
)
Note than many lisp routines and menu macros (and some users) will bypass this and call the original command.
Using a reactor might be a safer way of doing this.
rklee
2009-07-13, 09:58 PM
Your solution works, but when I try it there is a wait at the end until I pick a point in AutoCad. At that time it will reset the layer. I have not learned enough yet to take on reactors, but I am working on learning more.
Thank you.
rkmcswain
2009-07-13, 10:19 PM
...but when I try it there is a wait at the end until I pick a point in AutoCad.
I don't get that behavior. Tested in 2008 and 2010.
vBulletin® v3.6.7, Copyright ©2000-2009, Jelsoft Enterprises Ltd.