Converts a distance from a string to a real (double) value.
Supported platforms: Windows only
VBA:
RetVal = DistanceToReal(Distance, Unit)
Type: Utility
The object this method applies to.
Access: Input-only
Type: String
The distance as a string value.
Access: Input-only
Type: AcUnits enum
The unit to which the string is to be converted.
Type: Double
The distance as a real number.
No additional remarks.
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.")) )