Get All Viewports in All Layouts
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm confused, maybe someone can help.
I was trying to create a function to help another OP On This Post.
In short, this function should merely return all viewport enames from all layout tabs (EXCLUDING the "paper space" viewport.. [Viewport 1])
(defun GetViewports ( / ssVP vpList cnt)
(if (setq ssVP (ssget "_X" '((0 . "VIEWPORT")
(-4 . "<AND")
(-4 . "<NOT") (410 . "Model") (-4 . "NOT>")
(-4 . ">") (69 . 1)
(-4 . "AND>")
)));list/ssget/setq
(repeat (setq cnt (sslength ssVP))
(setq vpList (cons (ssname ssVP (setq cnt (1- cnt))) vpList))
);repeat
);if
);defun
BUT, I'm getting inconsistent results and cannot explain why?
I start a new drawing, which has 2 layouts by default (each with 1 viewport by default).
I am also defaulted to Model space. <-- This is important! do not change tabs yet!
When I run my function, only 1 viewport ename is returned (the viewport on Layout1), when I should get 2 viewports returned!
Command: (getviewports)
(<Entity name: 1ea74fc1bf0>)
Now, ONLY when I go to my last layout (Layout2), does my function return correctly...
Command: (getviewports)
(<Entity name: 1ea74fc1bf0> <Entity name: 1ea74fbf890>)
ALSO, if I add another Layout (do not switch to this layout yet!) and run it again, I still only get 2 viewports...
Command: (getviewports)
(<Entity name: 1ea74fc1bf0> <Entity name: 1ea74fbf890>)
And ONLY when I switch to Layout3 does my function finally return my 3rd layout...
Command: (getviewports)
(<Entity name: 1ea74fc1bf0> <Entity name: 1ea74fbf890> <Entity name: 1ea74fbf9e0>)
Any thoughts?! I have tried changing the 'ssget' call, to no avail. It just seems like a bug or something?
Best,
~DD