AddMText Method (ActiveX)

Creates an MText entity in a rectangle defined by the insertion point and width of the bounding box.

Supported platforms: Windows only

Signature

VBA:

RetVal = object.AddMText(InsertionPoint, Width, Text)
object

Type: Block, ModelSpace, PaperSpace

The object this method applies to.

InsertionPoint

Access: Input-only

Type: Variant (three-element array of doubles)

The insertion point of the MText bounding box.

Width

Access: Input-only

Type: Double

The width of the MText bounding box.

Text

Access: Input-only

Type: String

The actual text string for the MText object.

Return Value (RetVal)

Type: MText

The newly created MText object.

Remarks

No additional remarks.

Examples

VBA:

Sub Example_AddMtext()
    ' This example creates an MText object in model space.
    
    Dim MTextObj As AcadMText
    Dim corner(0 To 2) As Double
    Dim width As Double
    Dim text As String
    corner(0) = 0#: corner(1) = 10#: 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
    
End Sub

Visual LISP:

(vl-load-com)
(defun c:Example_AddMtext()
    ;; This example creates an MText object in model space.
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))
    
    ;; Define the multiline text object
    (setq corner (vlax-3d-point 0 10 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)
)