CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

ActiveX 开发指南

相关分类

DistanceToReal Method (ActiveX)

2023-1-4 10:43| 发布者: admin| 查看: 554| 评论: 0|来自: AutoCAD

摘要: 将字符串的距离转换为实数(双精度)值。

将字符串的距离转换为实数(双精度)值。

支持的平台:仅窗口

签名

工 务 局:

RetVal = DistanceToReal(Distance, Unit)
对象

类型:实用工具

此方法适用的对象。

距离

访问:仅输入

类型:字符串

以字符串值表示的距离。

单位

访问:仅输入

类型:枚举AcUnits

字符串要转换为的单位。

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

返回值(RetVal)

类型:

作为实数的距离。

言论

没有额外的评论。

例子

工 务 局:

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

路过

雷人

握手

鲜花

鸡蛋

最新评论

QQ|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1 )

GMT+8, 2024-5-19 14:30

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部