ActivePViewport Property (ActiveX)

Specifies the active paper space viewport for the drawing.

Supported platforms: Windows only

Signature

VBA:

object.ActivePViewport
object

Type: Document

The object this property applies to.

Property Value

Read-only: No

Type: PViewport

The active paper space viewport.

Remarks

A viewport must be set active using this property before you can see any changes to it.

Examples

VBA:

Sub Example_ActivePViewport()
   
    Dim newPViewport As AcadPViewport
    Dim centerPoint(0 To 2) As Double
    Dim height As Double
    Dim width As Double
    height = 5#
    width = 5#
    centerPoint(0) = 5#: centerPoint(1) = 5#: centerPoint(2) = 0#
    
    ' Create a paper space Viewport object
    ThisDrawing.ActiveSpace = acPaperSpace
    Set newPViewport = ThisDrawing.PaperSpace.AddPViewport(centerPoint, width, height)
    ZoomAll
    newPViewport.DISPLAY (True)
    
    ' Before making a paper space Viewport active,
    ' the mspace property needs to be True
    ThisDrawing.mspace = True
    ThisDrawing.ActivePViewport = newPViewport
End Sub

Visual LISP:

(vl-load-com)
(defun c:Example_ActivePViewport()
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))
  
    (setq centerPoint (vlax-3d-point 5 5 0)
          height 5.0
          width 5.0)
    
    ;; Create a paper space Viewport object
    (vla-put-ActiveSpace doc acPaperSpace)
    (setq paperSpace (vla-get-PaperSpace doc))
    (setq newPViewport (vla-AddPViewport paperSpace centerPoint width height))
    (vla-ZoomAll acadObj)
    (vla-Display newPViewport :vlax-true)
    
    ;; Before making a paper space Viewport active,
    ;; the mspace property needs to be True
    (vla-put-MSpace doc :vlax-true)
    (vla-put-ActivePViewport doc newPViewport)
)