Width Property (ActiveX)

Specifies the width of the object.

Supported platforms: Windows only

Signature

VBA:

object.Width
object

Type: Application, DgnUnderlay, Document, DwfUnderlay, GeomapImage, MText, OLE, PdfUnderlay, PointCloud, PViewport, RasterImage, Table, TextStyle, Toolbar, View, Viewport, Wipeout

The objects this property applies to.

Property Value

Read-only: No (except for the GeomapImage, RasterImage and Toolbar objects which are read-only)

Type: Double

The width of the given object. This value must be a positive, non-negative number.

Remarks

MText: Specifies the width of the text boundary in the current units. AutoCAD wraps the text within the text boundary, therefore the width must be a positive number large enough to accommodate the text. If the width is not large enough, the text may be difficult to read or may not be visible at all.



OLE: The width of an OLE object is the X axis measurement of the frame.

Table: The width of a table is the X axis measurement of the table.

TextStyle: Sets the character spacing. Entering a value of less than 1.0 condenses the text. Entering a value of greater than 1.0 expands it. The maximum value is 100.

Viewport: The width of a viewport is the X axis measurement of the viewport frame.

View: The width of a view is the X axis measurement of the area within a viewport that is used to display the model.

Raster: The width of the raster image in pixels.

Examples

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

Visual 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)))
)