;;;===================================
(defun c:kl ( / adoc *error* keeplayout layouts)

(vl-load-com)

(setq adoc
(vla-get-activedocument
(vlax-get-acad-object)
)
)

(defun *error* (msg)
(vla-endundomark adoc)
(cond
((member msg
'("Function cancelled"
"quit / exit abort"
"console break"
)
)
)
((princ (strcat " Error: " msg)))
)
(princ)
)

(setq keeplayout
(getstring "\nEnter the name of the layout to keep: ")
)

(if (member keeplayout (layoutlist))
(progn
(vla-startundomark adoc)
(vlax-for layout (setq layouts (vla-get-layouts adoc))
(if
(and
(/= (vla-get-name layout) "Model")
(/= (vla-get-name layout) keeplayout)
)
(vlax-invoke layout 'delete)
)
)
(vla-endundomark adoc)
)
(prompt
(strcat "\nLayout " keeplayout " does not exist.")
)
)
(princ)
)
;;;===================================
(c:kl)

Advertisements