CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

AutoCAD 2019 开发者帮助

ScaleFactor 属性 (ActiveX)

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

ScaleFactor 属性 (ActiveX)

指定对象的比例因子。

支持的平台:仅限 Windows

属性值

只读:

类型:双人房 (ACAD_NOUNITS)

大于 0.0 的实数。大于 1 的比例因子将放大对象。介于 0 和 1 之间的比例因子可缩小对象。

言论

此属性的初始值为 1.0000。

比例因子通常称为相对 X 比例因子。比例因子应用于对象的宽度,以允许独立于高度调整宽度。例如,如果比例因子值为 0.8,则绘制对象的宽度将是其正常未调整宽度的 80%。

Dimension、leader 和 tolerance 对象:此属性将覆盖 DIMSCALE 系统变量。

如果在图纸空间中工作,则尺寸的比例因子将等于 0.0,AutoCAD 将根据当前模型空间视口和图纸空间之间的比例计算合理的默认值。您将无法更改图纸空间中维度的比例因子。

例子

VBA:

Sub Example_ScaleFactor()
    ' This example creates a text object in model space.
    ' It then finds the current scale factor and changes it.
    Dim textObj As AcadText
    Dim textString As String
    Dim insertionPoint(0 To 2) As Double
    Dim height As Double
    
    ' Define the text object
    textString = "Hello, World."
    insertionPoint(0) = 2: insertionPoint(1) = 2: insertionPoint(2) = 0
    height = 0.5
    
    ' Create the text object in model space
    Set textObj = ThisDrawing.ModelSpace.AddText(textString, insertionPoint, height)
    ZoomAll
    
    ' Find the current scale factor for the text object
    Dim currScaleFactor As Double
    currScaleFactor = textObj.scalefactor
    MsgBox "The scale factor of the text is " & textObj.scalefactor, , "ScaleFactor Example"
    
    ' Change the scale factor for the text object
    textObj.scalefactor = currScaleFactor + 1
    ThisDrawing.Regen True
    MsgBox "The scale factor of the text is now " & textObj.scalefactor, , "ScaleFactor Example"
    
End Sub

可视化 LISP:

(vl-load-com)
(defun c:Example_ScaleFactor()
    ;; This example creates a text object in model space.
    ;; It then finds the current scale factor and changes it.
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))
    
    ;; Define the text object
    (setq textString "Hello, World."
          insertionPoint (vlax-3d-point 2 2 0)
          height 0.5)

    ;; Create the text object in model space
    (setq modelSpace (vla-get-ModelSpace doc))  
    (setq textObj (vla-AddText modelSpace textString insertionPoint height))
    (vla-ZoomAll acadObj)
    
    ;; Find the current scale factor for the text object
    (setq currScaleFactor (vla-get-Scalefactor textObj))
    (alert (strcat "The scale factor of the text is " (rtos currScaleFactor 2)))
    
    ;; Change the scale factor for the text object
    (vla-put-Scalefactor textObj (1+ currScaleFactor))
    (vla-Regen doc :vlax-true)
    (alert (strcat "The scale factor of the text is now " (rtos (vla-get-Scalefactor textObj) 2)))
)

路过

雷人

握手

鲜花

鸡蛋

最新评论

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

GMT+8, 2024-12-15 22:09

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部