Target Property (ActiveX)

Specifies the target point for the view or viewport.

Supported platforms: Windows only

Signature

VBA:

object.Target
object

Type: PViewport, View, Viewport

The objects this property applies to.

Property Value

Read-only: No

Type: Variant (three-element array of doubles)

A 3D WCS coordinate representing the target point.

Remarks

The line of sight is drawn from the center to the target point.



Examples

VBA:

Sub Example_Target()
    ' This example changes the target for a model space viewport.
    
    ' Create a new model space viewport
    Dim viewportObj As AcadViewport
    Set viewportObj = ThisDrawing.Viewports.Add("NewViewport")
    
    ' Add a circle
    Dim circleObj As AcadCircle
    Dim center(0 To 2) As Double
    Dim radius As Double
    center(0) = 0: center(1) = 0: center(2) = 0
    radius = 1
    Set circleObj = ThisDrawing.ModelSpace.AddCircle(center, radius)
    
    ' Find the current target
    Dim currTarget As Variant
    currTarget = viewportObj.target
    MsgBox "The current target is " & viewportObj.target(0) & ", " & viewportObj.target(1) & ", " & viewportObj.target(2), , "Target Example"
    
    ' Change the target
    Dim newTarget(0 To 2) As Double
    newTarget(0) = 2#: newTarget(1) = 2#: newTarget(2) = 0
    viewportObj.target = newTarget
    ThisDrawing.ActiveViewport = viewportObj
    ThisDrawing.Regen acAllViewports
    MsgBox "The new target is " & viewportObj.target(0) & ", " & viewportObj.target(1) & ", " & viewportObj.target(2), , "Target Example"
   
End Sub

Visual LISP:

(vl-load-com)
(defun c:Example_Target()
    ;; This example changes the target for a model space viewport.
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))

    ;; Create a new model space viewport
    (setq viewportObj (vla-Add (vla-get-Viewports doc) "NewViewport"))
    
    ;; Add a circle
    (setq center (vlax-3d-point 0 0 0)
          radius 1)

    (setq modelSpace (vla-get-ModelSpace doc))  
    (setq circleObj (vla-AddCircle modelSpace center radius))
    
    ;; Find the current target
    (setq currTarget (vlax-variant-value (vla-get-Target viewportObj)))
    (alert (strcat "The current target is " (rtos (vlax-safearray-get-element currTarget 0) 2) ", "
                                            (rtos (vlax-safearray-get-element currTarget 1) 2) ", "
                                            (rtos (vlax-safearray-get-element currTarget 2) 2)))
    
    ;; Change the target
    (setq newTarget (vlax-3d-point 2 2 0))
    (vla-put-Target viewportObj newTarget)
    (vla-put-ActiveViewport doc viewportObj)
    (vla-Regen doc acAllViewports)

    (setq currTarget (vlax-variant-value (vla-get-Target viewportObj)))
    (alert (strcat "The new target is " (rtos (vlax-safearray-get-element currTarget 0) 2) ", "
                                        (rtos (vlax-safearray-get-element currTarget 1) 2) ", "
                                        (rtos (vlax-safearray-get-element currTarget 2) 2)))
)