AngleToReal メソッド(ActiveX)

文字列の角度を実数値(倍精度浮動小数点数型)に変換します。

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

構文と要素

VBA:

RetVal = AngleToReal(Angle, Unit)
object

タイプ: Utility

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

Angle

アクセス: 入力のみ

タイプ: 文字列

角度の文字列値。

Unit

アクセス: 入力のみ

タイプ: acAngleUnits 列挙型

文字列の変換先の単位。

  • acDegrees
  • acDegreeMinuteSeconds
  • acGrads
  • acRadians

戻り値(RetVal)

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

角度の実数。

注意

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

VBA:

Sub Example_AngleToReal()
    ' This example passes several different strings representing
    ' an angle in different units to be converted to radians.
    
    Dim angAsStr As String
    Dim unit As Integer
    Dim angAsReal As Double
    
    ' Convert the angle given in degrees unit to a real
    angAsStr = "45"
    unit = acDegrees
    angAsReal = ThisDrawing.Utility.AngleToReal(angAsStr, unit)
    MsgBox "45 degrees converts to " & angAsReal & " radians.", , "AngleAsReal Example"
    
    ' Convert the angle given in degrees/minutes/seconds unit to Radians
    angAsStr = "45d0' 0"""
    unit = acDegreeMinuteSeconds
    angAsReal = ThisDrawing.Utility.AngleToReal(angAsStr, unit)
    MsgBox "45 degrees, 0 minutes, 0 seconds converts to " & angAsReal & " radians.", , "AngleAsReal Example"
    
    ' Convert the angle given in grads unit to Radians
    angAsStr = "50"
    unit = acGrads
    angAsReal = ThisDrawing.Utility.AngleToReal(angAsStr, unit)
    MsgBox "50 grads converts to " & angAsReal & " radians.", , "AngleAsReal Example"
    
End Sub

Visual LISP:

(vl-load-com)
(defun c:Example_AngleToReal()
    ;; This example passes several different strings representing
    ;; an angle in different units to be converted to radians.
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))

    ;; Convert the angle given in degrees unit to a real
    (setq angAsStr "45"
          unit acDegrees
          angAsReal (vla-AngleToReal (vla-get-Utility doc) angAsStr unit))
    (alert (strcat "45 degrees converts to " (rtos angAsReal 2) " radians."))
    
    ;; Convert the angle given in degrees/minutes/seconds unit to Radians
    (setq angAsStr "45d0' 0\""
          unit acDegreeMinuteSeconds
          angAsReal (vla-AngleToReal (vla-get-Utility doc) angAsStr unit))
    (alert (strcat "45 degrees, 0 minutes, 0 seconds converts to " (rtos angAsReal 2) " radians."))
    
    ;; Convert the angle given in grads unit to Radians
    (setq angAsStr "50"
          unit acGrads
          angAsReal (vla-AngleToReal (vla-get-Utility doc) angAsStr unit))
    (alert (strcat "50 grads converts to " (rtos angAsReal 2) " radians."))
)