CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

AutoCAD 2024 开发者帮助

SecondPoint 属性 (ActiveX)

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

SecondPoint 属性 (ActiveX)

指定射线或 x 线的第二个点。

支持的平台:仅限 Windows

签名

VBA:

object.SecondPoint
对象

类型:射线XLine

此属性应用于的对象。

属性值

只读:

类型:变体(双打的三元素阵列)

表示射线或 x 线的第二个点的 3D WCS 坐标。

言论

不能将光线的第二个点设置为等于其基点。

例子

VBA:

Sub Example_SecondPoint()
    ' This example creates a ray object. It then finds the
    ' second point of the ray, changes the second point, and
    ' queries the new second point.
    
    Dim basePoint(0 To 2) As Double
    Dim directionVec(0 To 2) As Double
    Dim rayObj As AcadRay
    Dim currSecondPoint As Variant
    Dim msg As String
    Dim newSecondPoint(0 To 2) As Double
    
    ' Establish the base point and directional vector for the ray
    basePoint(0) = 3: basePoint(1) = 3: basePoint(2) = 0
    directionVec(0) = 1:    directionVec(1) = 1: directionVec(2) = 0
    
    ' Create a Ray object in model space
    Set rayObj = ThisDrawing.ModelSpace.AddRay(basePoint, directionVec)
    
    ThisDrawing.Regen True
    MsgBox "A new Ray has been added.", vbInformation
    
    ' Define a new second point
    newSecondPoint(0) = 4: newSecondPoint(1) = 2: newSecondPoint(2) = 0
    
    ' Update the ray using the new second point
    rayObj.SecondPoint = newSecondPoint
            
    ' Query the new second point for the Ray
    currSecondPoint = rayObj.SecondPoint
    msg = currSecondPoint(0) & vbCrLf & _
          currSecondPoint(1) & vbCrLf & _
          currSecondPoint(2)
    
    ThisDrawing.Regen True
    MsgBox "We've just changed the second point of the new Ray to: " & vbCrLf & msg, vbInformation

End Sub

可视化 LISP:

(vl-load-com)
(defun c:Example_SecondPoint()
    ;; This example creates a ray object. It then finds the
    ;; second point of the ray, changes the second point, and
    ;; queries the new second point.
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))
    
    ;; Establish the base point and directional vector for the ray
    (setq basePoint (vlax-3d-point 3 3 0)
          directionVec (vlax-3d-point 1 1 0))
    
    ;; Create a Ray object in model space
    (setq modelSpace (vla-get-ModelSpace doc))  
    (setq rayObj (vla-AddRay modelSpace basePoint directionVec))
    
    (vla-Regen doc :vlax-true)
    (alert "A new Ray has been added.")
    
    ;; Define a new second point
    (setq newSecondPoint (vlax-3d-point 4 2 0))
    
    ;; Update the ray using the new second point
    (vla-put-SecondPoint rayObj newSecondPoint)
            
    ;; Query the new second point for the Ray
    (setq currSecondPoint (vlax-safearray->list (vlax-variant-value (vla-get-SecondPoint rayObj))))
    (setq msg (strcat (rtos (nth 0 currSecondPoint) 2) ", "
		      (rtos (nth 1 currSecondPoint) 2) ", "
		      (rtos (nth 2 currSecondPoint) 2)))
    
    (vla-Regen doc :vlax-true)
    (alert (strcat "We've just changed the second point of the new Ray to: " msg))
)

路过

雷人

握手

鲜花

鸡蛋

最新评论

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

GMT+8, 2025-3-28 17:24

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部