Active Viewports Zoom

Active Viewports Zoom

nathanwheeler27
Advocate Advocate
1,157 Views
3 Replies
Message 1 of 4

Active Viewports Zoom

nathanwheeler27
Advocate
Advocate

Hi,

Here is a sample of my code that I am having issues with. 

What I want is to split the screen in model space and zoom each window to specific coordinates. But, once I zoom the left window and go to the next window using vla-put-ActiveViewport, the previous vp (left window) zooms out.

Am I missing something? I have seen the UCSFOLLOW suggestion many times and it doesn't help.

 

(defun c:Example_ActiveViewport()

    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))
    
    ;; Returns current viewport of active document
    (setq currViewport (vla-get-ActiveViewport doc))

    (setq newViewport (vla-Add viewports "TESTVIEWPORT"))
    (vla-put-ActiveViewport doc newViewport)

    
    (setq viewports (vla-get-Viewports doc))

    (vlax-for entry viewports
        (setq lowerLeft (vlax-safearray->list (vlax-variant-value (vla-get-LowerLeftCorner entry))))
        (if (= (nth 0 lowerLeft) 0.000) (setq vp_left entry))
        (if (= (nth 0 lowerLeft) 0.500) (setq vp_right entry))
    )

    (vla-put-ActiveViewport doc vp_left)
    (vla-ZoomWindow acadObj (vlax-3d-point 0 0) (vlax-3d-point 100 100))

    (vla-put-ActiveViewport doc vp_right)
    (vla-ZoomWindow acadObj (vlax-3d-point 1000 1000) (vlax-3d-point 5000 5000))

)

 

0 Likes
Accepted solutions (2)
1,158 Views
3 Replies
Replies (3)
Message 2 of 4

Moshe-A
Mentor
Mentor
Accepted solution

@nathanwheeler27  hi,

 

i do not see in your code the creation of viewport configuration?  (-VPORTS command)

 

A named viewport configuration contains all the splitting windows created with -vports.

so when you call (vla-Add viewports "TESTVIEWPORT") you only create another viewport configuration for the current configuration (already created with -vports)

to make a  split window current use CVPORT command and then do your zoom.

 

Moshe

 

Message 3 of 4

nathanwheeler27
Advocate
Advocate
Accepted solution

Okay, using CVPORT, I was able to come up with something that works. Thank you.

 

(defun c:Example_ActiveViewport()

    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))
    
    (setq newViewport (vla-get-ActiveViewport doc))
    (vla-put-ActiveViewport doc newViewport)

    ;; Split the viewport in two windows
    (vla-Split newViewport acViewport2Vertical)
    (vla-put-ActiveViewport doc newViewport)
    

    (setvar 'CVPORT 2)
    (vla-ZoomWindow acadObj (vlax-3d-point 0 0) (vlax-3d-point 100 100))
    (alert "Pause")

    (setvar 'CVPORT 3)
    (vla-ZoomWindow acadObj (vlax-3d-point 11188.8 7399.12) (vlax-3d-point 11975.3 7689.61))

    (princ)
)

 

0 Likes
Message 4 of 4

Moshe-A
Mentor
Mentor

You are wellcome @nathanwheeler27 

 

glad i helped

 

Moshe

 

0 Likes