CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

AutoCAD 2020 开发者帮助

RealToString 方法 (ActiveX)

2024-5-18 18:20| 发布者: admin| 查看: 77| 评论: 0|原作者: admin|来自: AutoCAD

RealToString 方法 (ActiveX)

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

支持的平台:仅限 Windows

签名

VBA:

RetVal = object.RealToString(Value, Unit, Precision)
对象

类型: 实用程序

此方法应用到的对象。

价值

访问:仅输入

类型:

要转换的值。

单位

访问:仅输入

类型:枚举AcUnits

  • acDefaultUnits
  • acScientific
  • acDecimal
  • acEngineering
  • acArchitectural
  • acFractional
精度

访问:仅输入

类型:

值的精度。介于 0 和 8 之间的整数。

返回值 (RetVal)

类型:字符串

格式正确的字符串的值。

言论

没有其他评论。

例子

VBA:

Sub Example_RealToString()
    ' This example converts values in a given format to their string equivalents.
    
    Dim unit As Long
    Dim valueAsStr As String
    Dim precision As Integer
    Dim valueAsReal As Double
    precision = 6
    
    ' Convert a real value 17.5 using Scientific mode to a String
    unit = acScientific
    valueAsStr = ThisDrawing.Utility.RealToString(17.5, unit, precision)
    MsgBox "17.5 in scientific format is " & valueAsStr, , "RealToString Example"
    
    ' Convert a real value 17.5 using Decimal mode to a String
    unit = acDecimal
    valueAsStr = ThisDrawing.Utility.RealToString(17.5, unit, precision)
    MsgBox "17.5 in decimal format is " & valueAsStr, , "RealToString Example"
    
    ' Convert a real value 17.5 using Engineering mode to a String
    unit = acEngineering
    valueAsStr = ThisDrawing.Utility.RealToString(17.5, unit, precision)
    MsgBox "17.5 in engineering format is " & valueAsStr, , "RealToString Example"
    
    ' Convert a real value 17.5 using Architectural mode to a String
    unit = acArchitectural
    valueAsStr = ThisDrawing.Utility.RealToString(17.5, unit, precision)
    MsgBox "17.5 in architectural format is " & valueAsStr, , "RealToString Example"
    
    ' Converts a real value 17.5 using fractional mode to a String
    unit = acFractional
    valueAsStr = ThisDrawing.Utility.RealToString(17.5, unit, precision)
    MsgBox "17.5 in fractional format is " & valueAsStr, , "RealToString Example"
    
End Sub

可视化 LISP:

(vl-load-com)
(defun c:Example_RealToString()
    ;; This example converts values in a given format to their string equivalents.
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))
  
    (setq precision 6)
    
    ;; Convert a real value 17.5 using Scientific mode to a String
    (setq valueAsStr (vla-RealToString (vla-get-Utility doc) 17.5 acScientific precision))
    (alert (strcat "17.5 in scientific format is " valueAsStr))
    
    ;; Convert a real value 17.5 using Decimal mode to a String
    (setq valueAsStr (vla-RealToString (vla-get-Utility doc) 17.5 acDecimal precision))
    (alert (strcat "17.5 in decimal format is " valueAsStr))
    
    ;; Convert a real value 17.5 using Engineering mode to a String
    (setq valueAsStr (vla-RealToString (vla-get-Utility doc) 17.5 acEngineering precision))
    (alert (strcat "17.5 in engineering format is " valueAsStr))
    
    ;; Convert a real value 17.5 using Architectural mode to a String
    (setq valueAsStr (vla-RealToString (vla-get-Utility doc) 17.5 acArchitectural precision))
    (alert (strcat "17.5 in architectural format is " valueAsStr))
    
    ;; Converts a real value 17.5 using fractional mode to a String
    (setq valueAsStr (vla-RealToString (vla-get-Utility doc) 17.5 acFractional precision))
    (alert (strcat "17.5 in fractional format is " valueAsStr))
)

路过

雷人

握手

鲜花

鸡蛋

最新评论

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

GMT+8, 2024-12-15 12:51

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部