AngleFromXAxis メソッド(ActiveX)

X 軸からの線分の角度を取得します。

サポートされているプラットフォーム: Windows のみ

構文と要素

VBA:

RetVal = AngleFromXAxis(Point1, Point2)
object

タイプ: Utility

このメソッドが適用されるオブジェクト。

Point1

アクセス: 入力のみ

タイプ: バリアント型(3 要素の倍精度浮動小数点数型配列)

線分の始点。

Point2

アクセス: 入力のみ

タイプ: バリアント型(3 要素の倍精度浮動小数点数型配列)

線分の終点。

戻り値(RetVal)

タイプ: 倍精度浮動小数点数型

線分の角度(ラジアン)。

注意

追加の注意はありません。

VBA:

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)))
)