Target プロパティ(ActiveX)

ビューまたはビューポートの目標点を指定します。

サポートされているプラットフォーム: Windows のみ

構文と要素

VBA:

object.Target
object

タイプ: PViewportViewViewport

このプロパティが適用されるオブジェクト。

プロパティの値

読み込み専用: いいえ

タイプ: バリアント型(倍精度実数の 3 要素配列)

目標点を表す 3D WCS 座標

注意

中心から目標点まで視線が描かれます。



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)))
)