DistanceToReal メソッド(ActiveX)

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

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

構文と要素

VBA:

RetVal = DistanceToReal(Distance, Unit)
object

タイプ: Utility

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

Distance

アクセス: 入力のみ

タイプ: 文字列

距離の文字値

Unit

アクセス: 入力のみ

タイプ: AcUnits 列挙型

文字列が変換される単位。

  • acDefaultUnits
  • acScientific
  • acDecimal
  • acEngineering
  • acArchitectural
  • acFractional

戻り値(RetVal)

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

距離の実数値。

注意

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

VBA:

Sub Example_DistanceToReal()
    ' This example passes several different distances in
    ' different units to be converted to real values.
    
    Dim distAsString As String
    Dim unit As Long
    Dim distAsReal As Double
    
    ' Convert the distance to a real in scientific units
    unit = acScientific
    distAsString = "1.75E+01"
    distAsReal = ThisDrawing.Utility.DistanceToReal(distAsString, unit)
    MsgBox "1.75E+01 converts to " & distAsReal & " in scientific units.", , "DistanceToReal Example"
    
    ' Convert the distance to a real in decimal units
    unit = acDecimal
    distAsString = "17.5"
    distAsReal = ThisDrawing.Utility.DistanceToReal(distAsString, unit)
    MsgBox "1.75 converts to " & distAsReal & " in decimal units.", , "DistanceToReal Example"
    
    ' Convert the distance to a real in engineering units
    unit = acEngineering
    distAsString = "1'-5.50"""
    distAsReal = ThisDrawing.Utility.DistanceToReal(distAsString, unit)
    MsgBox "1'-5.50"" converts to " & distAsReal & " in engineering units.", , "DistanceToReal Example"
    
    ' Convert the distance to a real in architectural units
    unit = acArchitectural
    distAsString = "1'-5 1/2"""
    distAsReal = ThisDrawing.Utility.DistanceToReal(distAsString, unit)
    MsgBox "1'-5 1/2"" converts to " & distAsReal & " in architectural units.", , "DistanceToReal Example"
    
    ' Convert the distance to a real in fractional units
    unit = acFractional
    distAsString = "17 1/2"
    distAsReal = ThisDrawing.Utility.DistanceToReal(distAsString, unit)
    MsgBox "1'-5 1/2"" converts to " & distAsReal & " in fractional units.", , "DistanceToReal Example"
    
End Sub

Visual LISP:

(vl-load-com)
(defun c:Example_DistanceToReal()
    ;; This example passes several different distances in
    ;; different units to be converted to real values.
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))
  
    ;; Convert the distance to a real in scientific units
    (setq unit acScientific
          distAsString "1.75E+01"
          distAsReal (vla-DistanceToReal (vla-get-Utility doc) distAsString unit))
    (alert (strcat "1.75E+01 converts to " (rtos distAsReal 2) " in scientific units."))
    
    ;; Convert the distance to a real in decimal units
    (setq unit acDecimal
          distAsString "17.5"
	         distAsReal (vla-DistanceToReal (vla-get-Utility doc) distAsString unit))
    (alert (strcat "17.5 converts to " (rtos distAsReal 2) " in decimal units."))
    
    ;; Convert the distance to a real in engineering units
    (setq unit acEngineering
          distAsString "1'-5.50\""
	         distAsReal (vla-DistanceToReal (vla-get-Utility doc) distAsString unit))
    (alert (strcat "1'-5.50\" converts to " (rtos distAsReal 2) " in engineering units."))
    
    ;; Convert the distance to a real in architectural units
    (setq unit acArchitectural
          distAsString "1'-5 1/2\""
	         distAsReal (vla-DistanceToReal (vla-get-Utility doc) distAsString unit))
    (alert (strcat "1'-5 1/2\" converts to " (rtos distAsReal 2) " in architectural units."))
    
    ;; Convert the distance to a real in fractional units
    (setq unit acFractional
          distAsString "17 1/2"
	         distAsReal (vla-DistanceToReal (vla-get-Utility doc) distAsString unit))
    (alert (strcat "17 1/2 converts to " (rtos distAsReal 2) " in fractional units."))
)