@Anonymous wrote:
Hi,
I'm trying to create a very basic LISP routine that will:
-change to next Layout Tab
-Lock all viewport
-Zoom/Extent
...
Hi abonneau,
The 'layoutlist' function will return a list with all layouts in alphabetical order, not in tab order.
To change to the next layout, we'll have to get the actual tab order, to change to the 'next' layout.
To get the tab order, using AUTOLISP, we would have to look in ACAD_LAYOUT dictionary...
Using Visual LISP, it is easier, and the 'layout order' is a property from the Layout object in Layouts collection.
(vl-load-com)
(defun c:ne (/ acdoc aclyt app fstlyt lyts newlyt order)
(setq app (vlax-get-acad-object)
acdoc (vla-get-activedocument app)
aclyt (vla-get-activelayout acdoc)
lyts (vla-get-layouts acdoc)
order (vla-get-taborder aclyt)
)
(if (and (/= order 0) (> (getvar 'CVPORT) 1))
(command "_.pspace")
)
(vlax-for lyt lyts
(if (= (vla-get-taborder lyt) (1+ order))
(setq newlyt lyt)
)
(if (= (vla-get-taborder lyt) 1)
(setq fstlyt lyt)
)
)
(if newlyt
(vla-put-activelayout acdoc newlyt)
(vla-put-activelayout acdoc fstlyt)
)
(vlax-for blk (vla-get-block (vla-get-activelayout acdoc))
(if (= (vla-get-objectname blk) "AcDbViewport")
(vlax-put blk 'displaylocked -1)
)
)
(vla-ZoomExtents app)
(princ)
)
Hope this helps,
Henrique