How to get tha parent Layout of a Pviewport ?

How to get tha parent Layout of a Pviewport ?

Kh.mbkh
Advocate Advocate
394 Views
3 Replies
Message 1 of 4

How to get tha parent Layout of a Pviewport ?

Kh.mbkh
Advocate
Advocate

How to get tha parent Layout of a Pviewport ? or How to list all viewports in a given paper space Layout ?

0 Likes
395 Views
3 Replies
Replies (3)
Message 2 of 4

paullimapa
Mentor
Mentor

as a hint check out post by David Bethel here:

https://www.cadtutor.net/forum/topic/9694-select-a-specfic-viewport-on-layout-tab-with-code/


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 3 of 4

Sea-Haven
Mentor
Mentor

Here is some sample code that is based around Viewports I will let you work out which to use.

(setq ssvp (ssget "X" '((0 . "VIEWPORT")(cons 410 (getvar 'ctab )))))

(setq doc (vla-get-ActiveDocument (vlax-get-acad-object)))  
; Set the viewportsObj variable to the viewports list
(setq viewportsObj (vla-get-viewports (vlax-get-acad-object)))

;; Set the viewportObj variable to the activeviewport
(setq viewportObj (vla-get-ActiveViewport doc))

(setq len (sslength ss))
(setq x 0)

(repeat (sslength ss) 
(if (= (ssname ss x) viewportobj)
(setq (+ x 1))
)
)
; now know x

(if (= x 1)
(setq toviewportobj (ssname ss (- x 1)))
(setq toviewportobj (ssname ss (+ x 1)))
)
;; Reset the active viewport to see the change
(vla-put-ActiveViewport doc toviewportObj)
(vla-Regen doc acAllViewports)

0 Likes
Message 4 of 4

komondormrex
Mentor
Mentor

@Kh.mbkh 

what do you want it for exactly?

0 Likes