CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

ActiveX 开发指南

相关分类

AngleFromXAxis Method (ActiveX)

2023-1-4 11:57| 发布者: admin| 查看: 802| 评论: 0|来自: AutoCAD

摘要: 获取线条与 X 轴的角度。

获取线条与 X 轴的角度。

支持的平台:仅窗口

签名

工 务 局:

RetVal = AngleFromXAxis(Point1, Point2)
对象

类型:实用工具

此方法适用的对象。

要点1

访问:仅输入

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

线的起点。

要点2

访问:仅输入

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

行的端点。

返回值(RetVal)

类型:

线的角度(以弧度为单位)。

言论

没有额外的评论。

例子

工 务 局:

Sub Example_AngleFromXAxis()
    ' This example finds the angle, in radians, between the X axis
    ' and a line defined by two points.
    
    Dim pt1(0 To 2) As Double
    Dim pt2(0 To 2) As Double
    Dim retAngle As Double
    
    pt1(0) = 2: pt1(1) = 5: pt1(2) = 0
    pt2(0) = 5: pt2(1) = 2: pt2(2) = 0
    
    ' Return the angle
    retAngle = ThisDrawing.Utility.AngleFromXAxis(pt1, pt2)
    
    ' Create the line for a visual reference
    Dim lineObj As AcadLine
    Set lineObj = ThisDrawing.ModelSpace.AddLine(pt1, pt2)
    ZoomAll
    
    ' Display the angle found
    MsgBox "The angle in radians between the X axis and the line is " & retAngle, , "AngleFromXAxis Example"
    
End Sub

Visual LISP:

(vl-load-com)
(defun c:Example_AngleFromXAxis()
    ;; This example finds the angle, in radians, between the X axis
    ;; and a line defined by two points.
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))
  
    ;; Return the angle
    (setq pt1 (vlax-3d-point 2 5 0)
          pt2 (vlax-3d-point 5 2 0))
    (setq retAngle (vla-AngleFromXAxis (vla-get-Utility doc) pt1 pt2))
    
    ;; Create the line for a visual reference
    (setq modelSpace (vla-get-ModelSpace doc))
    (setq lineObj (vla-AddLine modelSpace pt1 pt2))

    (vla-ZoomAll acadObj)
    
    ;; Display the angle found
    (alert (strcat "The angle in radians between the X axis and the line is " (rtos retAngle 2)))
)

路过

雷人

握手

鲜花

鸡蛋

最新评论

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

GMT+8, 2024-5-12 01:57

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部