CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

AutoCAD 2025 开发者帮助

Direction 属性 (ActiveX)

2024-5-18 19:20| 发布者: admin| 查看: 109| 评论: 0|原作者: admin|来自: AutoCAD

Direction 属性 (ActiveX)

指定绘图的 3D 可视化的查看方向或表格的方向矢量。

支持的平台:仅限 Windows

签名

VBA:

object.Direction
对象

类型:ExtrudedSurfacePViewportTableViewViewport

此属性应用于的对象。

属性值

只读:
  • 否: AutoCAD
  • 否(对象除外):AutoCAD LTExtrudedSurface

类型:变体

表对象:向量(X 轴,以 WCS 坐标表示)定义包含表的水平面。

所有其他对象:向量是一个三元素的双精度数组,用于定义可查看绘图的方向。

言论

此属性使查看者能够查看绘图,就像从空间中的指定点回望原点 (0, 0, 0) 一样。此特性类似于 AutoCAD 中的 VPOINT 命令。

例子

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

可视化 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)))
)

路过

雷人

握手

鲜花

鸡蛋

最新评论

QQ|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1   苏公网安备32011402011833)

GMT+8, 2024-12-15 12:52

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部