Message 1 of 2
Save Layerstate of Model Space and Paper Space including all Viewports
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Below is my version of a lisp which will cycle through a drawing and save the Layerstate of:
Model Space
Paper Space Layouts
Paper Space Layout Viewports
To assist me, I have added the following to my Acaddoc.lsp
(setvar 'modemacro "VP $(getvar,CVPORT)")
Which was allways display the number of the Current Viewport in the status bar.
Any comments or suggestions to optimize the code are welcome.
;; Prepared by standing on the shoulders of others...
;; Many thanks to Henrique (hmsilva) for the bulk of this code
;; Many thanks to unknown author for the balance of this code
;; Many thanks to Henrique (hmsilva) for the bulk of this code
;; Many thanks to unknown author for the balance of this code
(defun c:LSSVPorts (/ _ctab layst nt i ss vp)
(Command "Model")
(Command "ZOOM" "E")
(Command "Model")
(Command "ZOOM" "E")
;; MODEL SPACE LAYERSTATE
(IF (layerstate-has (getvar "CTAB")) (layerstate-delete (getvar "CTAB")))
(COMMAND "-LAYER" "A" "S" (getvar "CTAB") "" "" "")
(princ)
(IF (layerstate-has (getvar "CTAB")) (layerstate-delete (getvar "CTAB")))
(COMMAND "-LAYER" "A" "S" (getvar "CTAB") "" "" "")
(princ)
(setq _ctab (getvar 'CTAB))
(foreach x (layoutlist)
(setvar 'CTAB x)
(if (and (= 0 (getvar "tilemode")) (>= (getvar "cvport") 2))
(command "_.pspace")
)
(command "_.zoom" "_E")
(foreach x (layoutlist)
(setvar 'CTAB x)
(if (and (= 0 (getvar "tilemode")) (>= (getvar "cvport") 2))
(command "_.pspace")
)
(command "_.zoom" "_E")
;;PAPERSPACE LAYOUT TAB LAYERSTATES
(IF (layerstate-has (getvar "CTAB")) (layerstate-delete (getvar "CTAB")))
(COMMAND "-LAYER" "A" "S" (getvar "CTAB") "" "" "")
(graphscr)
(princ)
(IF (layerstate-has (getvar "CTAB")) (layerstate-delete (getvar "CTAB")))
(COMMAND "-LAYER" "A" "S" (getvar "CTAB") "" "" "")
(graphscr)
(princ)
(if (setq ss (ssget "_X"
(list '(0 . "VIEWPORT")
'(-4 . "!=")
'(69 . 1)
(cons 410 x)
)
)
)
(repeat (setq i (sslength ss))
(setq hnd (ssname ss (setq i (1- i)))
ent (entget hnd)
vp (cdr (assoc 69 ent))
)
(if (> vp 1)
(progn
(if
(not
(and (= 0 (getvar "tilemode")) (>= (getvar "cvport") 2))
)
(command "_.mspace")
)
(setvar 'CVPORT vp)
(setq layst (strcat x " VP " (itoa vp)))
(list '(0 . "VIEWPORT")
'(-4 . "!=")
'(69 . 1)
(cons 410 x)
)
)
)
(repeat (setq i (sslength ss))
(setq hnd (ssname ss (setq i (1- i)))
ent (entget hnd)
vp (cdr (assoc 69 ent))
)
(if (> vp 1)
(progn
(if
(not
(and (= 0 (getvar "tilemode")) (>= (getvar "cvport") 2))
)
(command "_.mspace")
)
(setvar 'CVPORT vp)
(setq layst (strcat x " VP " (itoa vp)))
;;PAPERSPACE LAYOUT TAB VIEWPORT LAYERSTATES
(IF (layerstate-has layst) (layerstate-delete layst))
(COMMAND "-LAYER" "A" "S" layst "" "" "")
(graphscr)
(princ)
)
)
)
)
(command "_.pspace")
)
(setvar 'CTAB _ctab)
(princ)
)
)
)
)
(command "_.pspace")
)
(setvar 'CTAB _ctab)
(princ)
)