CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

ActiveX 开发指南

相关分类

方向矢量属性 (ActiveX)

2023-1-3 18:25| 发布者: admin| 查看: 373| 评论: 0|来自: AutoCAD

摘要: 指定光线、公差或通过矢量的xline的方向。

指定光线、公差或通过矢量的xline的方向。

支持的平台:仅窗口

签名

工 务 局:

object.DirectionVector
对象

类型:射线公差XLine

此属性适用的对象。

属性值

只读:

类型:变体(双精度的三元素数组)

光线、公差或构造线 (XLine) 的方向。

言论

没有额外的评论。

例子

工 务 局:

Sub Example_DirectionVector()
    ' This example creates a ray and then changes the direction vector
    ' for the ray.
    
    Dim rayObj As AcadRay
    Dim basePoint(0 To 2) As Double
    Dim SecondPoint(0 To 2) As Double
    Dim newDirectionVec(0 To 2) As Double
    
    basePoint(0) = 3#: basePoint(1) = 3#: basePoint(2) = 0#
    SecondPoint(0) = 1#: SecondPoint(1) = 3#: SecondPoint(2) = 0#
    
    ' Create a Ray object in model space
    Set rayObj = ThisDrawing.ModelSpace.AddRay(basePoint, SecondPoint)
    ZoomAll
    MsgBox "The ray has a direction vector of " & rayObj.DirectionVector(0) & ", " & rayObj.DirectionVector(1) & ", " & rayObj.DirectionVector(2), vbInformation, "DirectionVector Example"
    
    ' Change the direction vector
    newDirectionVec(0) = 3#: newDirectionVec(1) = 1#: newDirectionVec(2) = 0#
    rayObj.DirectionVector = newDirectionVec
            
    ' Query the new direction vector for the Ray
    Dim retDir As Variant            ' Note that return from DirectionVector property is Variant and not a SafeArray
    retDir = rayObj.DirectionVector
    
    ThisDrawing.Regen True
    MsgBox "The direction vector of the ray has been changed to " & rayObj.DirectionVector(0) & ", " & rayObj.DirectionVector(1) & ", " & rayObj.DirectionVector(2), vbInformation, "DirectionVector Example"
    
End Sub

Visual LISP:

(vl-load-com)
(defun c:Example_DirectionVector()
    ;; This example creates a ray and then changes the direction vector
    ;; for the ray.
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))

    (setq basePoint (vlax-3d-point 3 3 0)
          SecondPoint (vlax-3d-point 1 3 0))
    
    ;; Create a Ray object in model space
    (setq modelSpace (vla-get-ModelSpace doc))  
    (setq rayObj (vla-AddRay modelSpace basePoint SecondPoint))
    (vla-ZoomAll acadObj)
  
    (setq vDirection (vlax-safearray->list (vlax-variant-value (vla-get-DirectionVector rayObj))))
    (alert (strcat "The ray has a direction vector of "
	           "\n" (rtos (nth 0 vDirection) 2) "," (rtos (nth 1 vDirection) 2) "," (rtos (nth 2 vDirection) 2)))
    
    ;; Change the direction vector
    (setq newDirectionVec (vlax-3d-point 3 1 0))
    (vla-put-DirectionVector rayObj newDirectionVec)
            
    ;; Query the new direction vector for the Ray
    (setq retDir (vlax-safearray->list (vlax-variant-value (vla-get-DirectionVector rayObj))))
    
    (vla-Regen doc :vlax-true)
    (alert (strcat "The direction vector of the ray has been changed to "
	           "\n" (rtos (nth 0 retDir) 2) "," (rtos (nth 1 retDir) 2) "," (rtos (nth 2 retDir) 2)))
)

路过

雷人

握手

鲜花

鸡蛋

最新评论

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

GMT+8, 2024-5-12 06:24

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部