;############################### ;### LayerState Switcher ### ;############################### ;version 3.2 ;Matthew D. Jordan - http://scenic-shop.com ; ;This is a command transparently saves the current layerstate. Subsequent invocations ;switch between the saved state and the current state. You can go back and forth until ;your eyes pop out. ; ;command: LSS ; - on first run, it will save a layerstate and exit the command ; - option: Previous - (default option), switches you to the saved layerstate, and saves the ; current layerstate. ; - option: Update - saves the current layerstate for future retrieval. ; - option: Clear - delete the auto-generated layerstates that this script creates. ; - option: eXit - duh. (defun c:lss( / *error* ) ;in case of chemical attack... (defun *error* (msg) (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*") (princ (strcat "\n** Error: " msg " **"))) (princ) ) ;is this the first time using this utility? If so, save a new layerstate... (if (not (layerstate-has "layerstate_switcher_temp_1")) (progn (layerstate-save "layerstate_switcher_temp_1" 255 nil) (prompt "\nLayerstate switcher initialized...") (princ) (quit) ) ) ;purge extra layerstates (if (layerstate-has "layerstate_switcher_temp_2") (layerstate-delete "layerstate_switcher_temp_2") ) (initget "Previous Update Clear eXit") (or (setq answer (getkword "\nEnter an Layerstate Switch option [Previous/Update/Clear all/eXit] : ")) (setq answer "Previous") ) ;or (cond ((= answer "Previous") (progn (layerstate-save "layerstate_switcher_temp_2" 255 nil) (layerstate-restore "layerstate_switcher_temp_1" nil) (layerstate-delete "layerstate_switcher_temp_1") (layerstate-rename "layerstate_switcher_temp_2" "layerstate_switcher_temp_1") (prompt "\nLayerstate restored...") ) ) ((= answer "Update") (progn (layerstate-delete "layerstate_switcher_temp_1") (layerstate-save "layerstate_switcher_temp_1" 255 nil) (prompt "\nLayerstate updated...") ) ) ((= answer "Clear") (progn (layerstate-delete "layerstate_switcher_temp_1") (prompt "\nTemporary layerstates cleared...") ) ) ((= answer "eXit")) ) ;cond (princ) )