DistanceToReal 方法 (ActiveX)
将字符串的距离转换为实数(双精度)值。 支持的平台:仅限 Windows 签名VBA: RetVal = DistanceToReal(Distance, Unit)
返回值 (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 可视化 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.")) ) |
|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1 苏公网安备32011402011833)
GMT+8, 2024-12-15 11:34
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.