We have a LISP routine here that sets up our layers automatically. The problem we have is that the routine essentially errors out if the user has any layers that are frozen or locked.
My thought was to use the code found in this thread to create a temporary layer state, unlock all the layers on, thaw them, then revert to the temporary layer state.
I was able to save, restore & delete the layer state using simple syntax in the LISP routine, but for some reason it invokes the AutoCAD text window when the code is run this way. Here's a sample of the code I was using:
(vl-load-com)
(defun C:MakeLAYER ()
(setvar "cmdecho" 0)
(command ".undo" "begin")
(setq ccl (getvar "clayer"))
;
;
(command "-layer" "state" "save" "PreMakelayer" "" "" "")
(command "-layer" "on" "*" "thaw" "*" "unlock" "*" "")
;
;
(setq curlayer "BASEPLATE")
(command "-layer" "m" curlayer "c" "GREEN" curlayer "")
(SetLayerDescription curlayer "Baseplate Outline and Mounting Holes")
(setq curlayer "END")
;
;
(command "-layer" "state" "restore" "PreMakelayer" "" "")
(command "-layer" "state" "delete" "PreMakeLayer" "" "")
;
;
(setq curlayer "END")
(setvar "clayer" ccl)
(command ".undo" "end")
(princ)
)
My problem is this: I'm not sure how to use the code in this thread (though it seems to be what I'm looking for) in order to save a layer state, restore it later on, then delete it.
For example, from the code that CAB last posted, I see this:
(defun save-layerstate (obj name mask)
(if (vl-catch-all-error-p
(vl-catch-all-apply
'vla-save
(list obj name mask)))
nil
T))
So, if I were to want to save a layer state called "PreMakeLayer", what syntax would I use? My assumption was:
(save-layerstate "PreMakeLayer")
, but that returns error: too few arguments.
Can someone help a newb along here & clue me in as to how this code is supposed to work? I'd really appreciate it!