AddPViewport Method (ActiveX)

Adds a paper space viewport, given the center, height, and width.

Supported platforms: Windows only

Signature

VBA:

RetVal = object.AddPViewport(Center, Width, Height)
object

Type: PaperSpace

The object this method applies to.

Center

Access: Input-only

Type: Variant (three-element array of doubles)

The center coordinates of the viewport.

Width

Access: Input-only

Type: Double

The width of the viewport. Must be a positive number.

Height

Access: Input-only

Type: Double

The height of the viewport. Must be a positive number.

Return Value (RetVal)

Type: PViewport

The newly created PViewport object.

Remarks

No additional remarks.

Examples

VBA:

Sub Example_AddPViewport()
    ' This example creates a new paper space viewport
    
    Dim pviewportObj As AcadPViewport
    Dim center(0 To 2) As Double
    Dim width As Double
    Dim height As Double
    
    ' Define the paper space viewport
    center(0) = 3: center(1) = 3: center(2) = 0
    width = 40
    height = 40
    
    ' Change from model space to paper space
    ThisDrawing.ActiveSpace = acPaperSpace
    
    ' Create the paper space viewport
    Set pviewportObj = ThisDrawing.PaperSpace.AddPViewport(center, width, height)
    
    ThisDrawing.Regen acAllViewports
    
End Sub

Visual LISP:

(vl-load-com)
(defun c:Example_AddPViewport()
    ;; This example creates a new paper space viewport
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))
  
    ;; Define the paper space viewport
    (setq center (vlax-3d-point 3 3 0)
          width 40
          height 40)
    
    ;; Change from model space to paper space
    (vla-put-ActiveSpace doc acPaperSpace)
    
    ;; Create the paper space viewport
    (setq paperSpace (vla-get-PaperSpace doc))
    (setq pviewportObj (vla-AddPViewport paperSpace center width height))

    ;; Turn the viewport on, by default it is off
    (vla-Display pviewportObj :vlax-true)
    
    (vla-Regen doc acAllViewports)
)