Width 属性 (ActiveX)
指定对象的宽度。 支持的平台:仅限 Windows 签名VBA: object.Width
属性值只读:
类型:双 给定对象的宽度。此值必须为正数、非负数。 言论MText:指定文本边界的宽度(以当前单位表示)。AutoCAD 将文本换行在文本边界内,因此宽度必须为足够大以容纳文本的正数。如果宽度不够大,文本可能难以阅读或根本看不到。 OLE:OLE 对象的宽度是帧的 X 轴度量值。 表格:表格的宽度是表格的 X 轴测量值。 TextStyle:设置字符间距。输入小于 1.0 的值会压缩文本。输入大于 1.0 的值会将其展开。最大值为 100。 视口:视口的宽度是视口框的 X 轴度量值。 视图:视图的宽度是用于显示模型的视口内面积的 X 轴测量值。 光栅:光栅图像的宽度(以像素为单位)。 例子VBA: Sub Example_Width() ' This example creates an MText object in model space. ' It then changes the width of the MText object. Dim MTextObj As AcadMText Dim corner(0 To 2) As Double Dim width As Double Dim text As String corner(0) = 0: corner(1) = 5: corner(2) = 0 width = 10 text = "This is the text String for the mtext Object" ' Creates the mtext Object Set MTextObj = ThisDrawing.ModelSpace.AddMText(corner, width, text) ZoomAll ' Find the current width of the mtext object width = MTextObj.width MsgBox "The current width of the mtext object is " & MTextObj.width, , "Width Example" ' Change the width of the mtext object MTextObj.width = width / 2 MTextObj.Update MsgBox "The new width of the mtext object is " & MTextObj.width, , "Width Example" End Sub 可视化 LISP: (vl-load-com) (defun c:Example_Width() ;; This example creates an MText object in model space. ;; It then changes the width of the MText object. (setq acadObj (vlax-get-acad-object)) (setq doc (vla-get-ActiveDocument acadObj)) (setq corner (vlax-3d-point 0 5 0) width 10 text "This is the text String for the mtext Object") ;; Creates the mtext Object (setq modelSpace (vla-get-ModelSpace doc)) (setq MTextObj (vla-AddMText modelSpace corner width text)) (vla-ZoomAll acadObj) ;; Find the current width of the mtext object (setq width (vla-get-width MTextObj)) (alert (strcat "The current width of the mtext object is " (rtos width 2))) ;; Change the width of the mtext object (vla-put-width MTextObj (/ width 2)) (vla-Update MTextObj) (alert (strcat "The new width of the mtext object is " (rtos (vla-get-width MTextObj) 2))) ) |
|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1 苏公网安备32011402011833)
GMT+8, 2024-12-15 12:50
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.