;; CAB 07.02.2014
;; Create layer states from each viewport
;; Ignore VP with no frozen layers
(defun c:vp2ls
() (c:vp2layerStates
)) (defun c:vp2layerStates
(/ a b c tab ll ln ss layerlist layerdict ls_manager
clayname obj newlsn lsn nam)
;; unlock and thaw all layers
(defun layerprep
(doc
/ lays lay
) )
)
;; freeze a list of layers
(defun freezelayers
(ll doc
/ lays lay
) )
;; save a layer state from current layers
(defun ls_save
(name lsm
) ;; Save the Named LayerState
name
)
)
(defun LayerMake
(LName LColor LType
) '(0 . "LAYER")
'(100 . "AcDbSymbolTableRecord")
'(100 . "AcDbLayerTableRecord")
(cons 2 LName
) ;layer name (cons 62 LColor
) ;layer color '(70 . 0) ; on, unlocked, thawed
)
)
)
)
(defun getstatenames
( doc
/ nams dict obj
) )
nams
)
)
(LayerMake "Tmp9z1x" 1 "x") ; temp layer to make current
(ls_save "CurrentStateFound" ls_manager) ; save current state
layerlist nil
)
(layerprep *activedoc) ; thaw all
)
)
)
(freezelayers layerlist *activedoc)
newlsn))
)
)
)
)
) ; end foreach
)
(vl
-catch
-all
-apply 'vla
-restore
(list ls_manager nam
)) ;; (vl-catch-all-apply 'vla-delete (list ls_manager nam)) ; in case you want to delete the temp state
)
)
)
(princ "\n Layer States") )