(defun PM-LSR (/ layerstatenam)
(setvar "tilemode" 0)
(cond
((= (getvar "ctab") "A1-0 SITE")(setq layerstatenam "SITE"))
((= (getvar "ctab") "A1-1 DRIVE-THRU")(setq layerstatenam "DRIVE-THRU"))
((= (getvar "ctab") "A2-0 PHOTO")(setq layerstatenam "PHOTO-FLOOR"))
((= (getvar "ctab") "A3-0 FLOOR")(setq layerstatenam "FP"))
((= (getvar "ctab") "A3-1 CEILING")(setq layerstatenam "CEILING"))
((= (getvar "ctab") "A4-0 EXT ELEVS")(setq layerstatenam "ELEVATIONS"))
((= (getvar "ctab") "K2-0 KITCHEN")(setq layerstatenam "KITCHEN"))
)
(layerstate-restore "ALL-ON" nil 255)
(layerstate-restore layerstatenam nil 255)
(command "regenall")
(princ (strcat "\n* Restoring Layer States from: " layerstatenam))
(princ))
(defun Layerstate:Start ()
(or *LS-Reactor*
(setq *LS-Reactor*
(vlr-command-reactor
nil
'(
(:vlr-commandcancelled . LS-Reactor:CommandEnded)
(:vlr-commandended . LS-Reactor:CommandEnded)
(:vlr-commandfailed . LS-Reactor:CommandEnded)
(:vlr-commandwillstart . LS-Reactor:CommandWillStart)
)
)
)
)
(defun LS-Reactor:CommandEnded ()
?
)
(defun LS-Reactor:CommandWillStart ()
?
)
(defun LSon nil
(and (LSrtr t) (alert "\nLayer states reactor is activated, type \"LSoff\" to turn it off."))
)
(defun LSoff nil
(and (LSrtr nil) (alert "\nLayer states reactor is disabled, type \"LSon\" to turn it on."))
)
(defun LSrtr ( flg )
(foreach rtr (cdar (vlr-reactors :VLR-SysVar-reactor)) (if (= "LSrtr" (vlr-data rtr)) (vlr-remove rtr)) )
(if flg (vlr-SysVar-Reactor "LSrtr" '((:VLR-sysVarChanged . CB:LSrtr)))) t
)
(defun CB:LSrtr ( rtr args )
(and (equal '("TILEMODE" T) args)
(setq args
(cdr
(assoc
(getvar 'ctab)
'(
("A1-0 SITE" . "SITE")
("A1-1 DRIVE-THRU" . "DRIVE-THRU")
("A2-0 PHOTO" . "PHOTO-FLOOR")
("A3-0 FLOOR" . "FP")
("A3-1 CEILING" . "CEILING")
("A4-0 EXT ELEVS" . "ELEVATIONS")
("K2-0 KITCHEN" . "KITCHEN")
)
)
)
)
(vl-catch-all-error-p (setq rtr (vl-catch-all-apply 'eval '((progn (layerstate-restore "ALL-ON" nil 255) (layerstate-restore args nil 255))))))
(alert (strcat "\nError occured: \n" (vl-catch-all-error-message rtr)))
)
(princ)
)
(vl-load-com) (princ)
BTW the subfunctions in CAB's code are handy, as they provide alternative for the layerstate-restore (which is a floating sand <EXRXSUBR>).
Impressive work CAB, (considering its from 2004).
*blink-blink* ...How about just: "...<snip>... Impressive work, CAB.".
Ah, well okay, that's "situation normal" for TheSwamp. You've heard the saying: "We all stand on the shoulders of giants." Well, here be where they roam--or, in some cases, were but you'll know they were here by their foot prints-. This place has taught quite a few giants.
And, you should also just accept CABs code is solid (be shocked when it's not).
Is there awallway using your routine to run a regenall? This is what is missing to show the effects of the layerstate restore.
OOPS
In BricsCAD I get this message:
Error: bad argument type <NIL> ; expected ENTITYNAME at [layerstate-restore]
; LISP execution error : inside <LAYERSTATE-CALLBACK> at [VLR-Miscellaneous-Reactor:vlr-layoutSwitched]