Direction Property (ActiveX)

Specifies the viewing direction for a 3D visualization of the drawing, or the direction vector of the table.

Supported platforms: Windows only

Signature

VBA:

object.Direction
object

Type: ExtrudedSurface, PViewport, Table, View, Viewport

The objects this property applies to.

Property Value

Read-only: No

Type: Variant

Table objects: The vector (X axis, in WCS coordinates) defines the horizontal plane containing the table.

All other objects: The vector is a three-element array of doubles that defines a direction from which the drawing can be viewed.

Remarks

This property puts the viewer in a position to look at the drawing as if looking back at the origin (0, 0, 0) from a specified point in space. This property is similar to the VPOINT command in AutoCAD.

Examples

VBA:

Sub Example_Direction()
    ' This example creates a circle in model space
    ' and changes the thickness of the circle. Once
    ' the thickness has been changed, the direction
    ' of the active viewport is changed so that the
    ' new thickness setting is visible.
   
    Dim circleObj As AcadCircle
    Dim centerPoint(0 To 2) As Double
    Dim radius As Double
    
    ' Define the circle
    centerPoint(0) = 0#: centerPoint(1) = 0#: centerPoint(2) = 0#
    radius = 5#
    
    ' Create the Circle object in model space
    Set circleObj = ThisDrawing.ModelSpace.AddCircle(centerPoint, radius)
        
    ' Change the thickness of the circle
    circleObj.Thickness = 3
    
    ' Change the direction of the viewport so that you can
    ' view the change made to the thickness. Once you change
    ' the direction, you must reset the active viewport.
    Dim NewDirection(0 To 2) As Double
    NewDirection(0) = -1: NewDirection(1) = -1: NewDirection(2) = 1
    ThisDrawing.ActiveViewport.direction = NewDirection
    ThisDrawing.ActiveViewport = ThisDrawing.ActiveViewport
    
End Sub


Sub example_tableDirection()
    Dim oMS As AcadModelSpace
    Set oMS = ThisDrawing.ModelSpace
    Dim oT As AcadTable
    Dim pt(2) As Double
    Set oT = oMS.AddTable(pt, 4, 5, 5, 20)
    ZoomExtents
    Dim vDirection As Variant
    vDirection = oT.Direction
    MsgBox "Table Direction vector is " & vbCrLf & vDirection(0) & "," & vDirection(1) & "," & vDirection(2)

    Dim vNewDirection(2) As Double
    vNewDirection(0) = 0
    vNewDirection(1) = 1
    vNewDirection(2) = 0
    oT.Direction = vNewDirection
    
    Dim vRetDirection As Variant
    vRetDirection = oT.Direction
    MsgBox "New Table Direction vector is " & vbCrLf & vRetDirection(0) & "," & vRetDirection(1) & "," & vRetDirection(2)
End Sub

Visual LISP:

(vl-load-com)
(defun c:Example_Direction()
    ;; This example creates a circle in model space
    ;; and changes the thickness of the circle. Once
    ;; the thickness has been changed, the direction
    ;; of the active viewport is changed so that the
    ;; new thickness setting is visible.
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))
    
    ;; Define the circle
    (setq centerPoint (vlax-3d-point 0 0 0)
          radius 5)

    ;; Create the Circle object in model space
    (setq modelSpace (vla-get-ModelSpace doc))  
    (setq circleObj (vla-AddCircle modelSpace centerPoint radius))
        
    ;; Change the thickness of the circle
    (vla-put-Thickness circleObj 3)
    
    ;; Change the direction of the viewport so that you can
    ;; view the change made to the thickness. Once you change
    ;; the direction, you must reset the active viewport.
    (setq NewDirection (vlax-3d-point -1 -1 1))
    (setq activeViewport (vla-get-ActiveViewport doc))
    (vla-put-Direction activeViewport NewDirection)
    (vla-put-ActiveViewport doc activeViewport)
)

(defun c:Example_TableDirection()
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))
    (setq modelSpace (vla-get-ModelSpace doc))
  
    (setq pt (vlax-3d-point 0 0 0)
          oT (vla-AddTable modelSpace pt 4 5 5 20))

    (vla-ZoomExtents acadObj)
    (setq vDirection (vlax-safearray->list (vlax-variant-value (vla-get-Direction oT))))
    (alert (strcat "Table Direction vector is "
	           "\n" (rtos (nth 0 vDirection) 2) "," (rtos (nth 1 vDirection) 2) "," (rtos (nth 2 vDirection) 2)))

    (setq vNewDirection (vlax-3d-point 0 1 0))
    (vla-put-Direction oT vNewDirection)
    
    (setq vRetDirection (vlax-safearray->list (vlax-variant-value (vla-get-Direction oT))))
    (alert (strcat "New Table Direction vector is "
	           "\n" (rtos (nth 0 vRetDirection) 2) "," (rtos (nth 1 vRetDirection) 2) "," (rtos (nth 2 vRetDirection) 2)))
)