@ibfmm wrote:
... LISPs for AutoCAD - but I'm looking for some to change the current layer (after executing a command) to a specific one and then swicht back to the current.
....
I believe the Architectural overlay program has this capability built in, but I'm not sure whether other overlay programs do.
Another approach would be to not change the current Layer before drawing something, but so that you don't have to change the current Layer back afterwards, instead change the something to the desired Layer after drawing it. In simplest terms:
(command "_.undefine" "INSERT")
(defun C:INSERT ()
(command "_.layer" "_new" "BLOCK" ""); in case it doesn't exist yet; does not make it current
(command "_.insert")
(while (> (getvar 'cmdactive) 0) (command pause))
(command "_.chprop" "_last" "" "_layer" "BLOCK" "")
); defun
Or, you could take advantage of a peculiarity I discovered some time ago -- if you give an object a Layer using (subst) & (entmod), if the Layer doesn't yet exist, it will create the Layer in the process [using default color 7 and continuous linetype], so you don't even need to account for the possibility that it's not in the drawing yet:
(command "_.undefine" "INSERT")
(defun C:INSERT ()
(command "_.insert")
(while (> (getvar 'cmdactive) 0) (command pause))
(entmod (subst (cons 8 "BLOCK") (assoc 8 (setq edata (entget (entlast)))) edata))
); defun
However, those approaches have at least one drawback that I can think of in the TEXT command. You can make more than one Text object in a single command, by picking new insertion points along the way. Those approaches would put only the last one on the designated Layer. But a more sophisticated routine could account for that [mark the last object in the drawing before starting, and change the Layer of everything newer than that when done].
Kent Cooper, AIA