Normal 属性 (ActiveX)
指定对象的三维法线单位向量。 支持的平台:仅限 Windows 签名VBA: object.Normal
属性值只读:不 类型:变体(双打的三元素阵列) WCS 中的 3D 法向单位向量。 言论此法向量定义给定对象的 Z 轴。尽管在 WCS 中返回法线,但它可用于确定对象的 OCS。在将坐标与 OCS 相互转换时,在方法中使用此属性作为 OCSNormal。TranslateCoordinates 请注意,此属性指定向量,而不是点。向量定义法线的方向,而不是空间中的位置。您可以将此法向量添加到一个点以获得另一个点。 公差:法向量必须垂直于物体的方向。不垂直于 Tolerance 对象的法线将生成错误。Tolerance 例子VBA: Sub Example_Normal() ' This example creates a circle in model space. ' It then finds the current normal to that circle ' and changes the normal. ' Define a circle Dim circleObj As AcadCircle Dim center(0 To 2) As Double Dim radius As Double center(0) = 4: center(1) = 4: center(2) = 0 radius = 1 ' Add the circle to model space Set circleObj = ThisDrawing.ModelSpace.AddCircle(center, radius) ZoomAll ' Find the normal for the circle Dim currNormal As Variant currNormal = circleObj.Normal MsgBox "The current normal for the circle is " & circleObj.Normal(0) & ", " & circleObj.Normal(1) & ", " & circleObj.Normal(2), , "Normal Example" ' Change the normal for the circle Dim newNormal(0 To 2) As Double newNormal(0) = 1: newNormal(1) = 1: newNormal(2) = -1 circleObj.Normal = newNormal circleObj.Update MsgBox "The current normal for the circle is " & circleObj.Normal(0) & ", " & circleObj.Normal(1) & ", " & circleObj.Normal(2), , "Normal Example" End Sub 可视化 LISP: (vl-load-com) (defun c:Example_Normal() ;; This example creates a circle in model space. ;; It then finds the current normal to that circle ;; and changes the normal. (setq acadObj (vlax-get-acad-object)) (setq doc (vla-get-ActiveDocument acadObj)) ;; Define a circle (setq center (vlax-3d-point 4 4 0) radius 1) ;; Add the circle to model space (setq modelSpace (vla-get-ModelSpace doc)) (setq circleObj (vla-AddCircle modelSpace center radius)) (vla-ZoomAll acadObj) ;; Find the normal for the circle (setq currNormal (vlax-variant-value (vla-get-Normal circleObj))) (alert (strcat "The current normal for the circle is " (rtos (vlax-safearray-get-element currNormal 0) 2) ", " (rtos (vlax-safearray-get-element currNormal 1) 2) ", " (rtos (vlax-safearray-get-element currNormal 2) 2))) ;; Change the normal for the circle (setq newNormal (vlax-3d-point 1 1 -1)) (vla-put-Normal circleObj newNormal) (vla-Update circleObj) (setq newNormal (vlax-variant-value newNormal)) (alert (strcat "The current normal for the circle is " (rtos (vlax-safearray-get-element newNormal 0) 2) ", " (rtos (vlax-safearray-get-element newNormal 1) 2) ", " (rtos (vlax-safearray-get-element newNormal 2) 2))) ) |
|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1 苏公网安备32011402011833)
GMT+8, 2024-12-15 22:23
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.