AttachmentPoint Property (ActiveX)

Specifies the attachment point for an MText object.

Supported platforms: Windows only

Signature

VBA:

object.AttachmentPoint
object

Type: MText

The object this property applies to.

Property Value

Read-only: No

Type: acAttachmentPoint enum

Remarks

The attachment point specifies where the insertion point aligns with the text boundary. The option you select determines both the text justification and text spill in relation to the text boundary. The options for text justification are Left, Right, and Center. The options for text spill are Top, Mid (middle), and Bottom.



Top Left

left-justified, spills down



Top Center

center-justified, spills down



Top Right

right-justified, spills down



Mid Left

left-justified, spills up and down



Mid Center

center-justified, spills up and down



Mid Right

right-justified, spills up and down



Bottom Left

left-justified, spills up



Bottom Center

center-justified, spills up



Bottom Right

right-justified, spills up

When the AttachmentPoint property is changed, the position of the existing bounding box does not change; the text is simply rejustified within the bounding box. However, the InsertionPoint property reflects the coordinates of the attachment point being used, so the value of the InsertionPoint property will change to reflect the change in justification.

Examples

VBA:

Sub Example_AttachmentPoint()
    Dim MTextObj As AcadMText
    Dim width As Double
    Dim text As String
    Dim count As Integer
    Dim attachPoint As String
    Dim corner(0 To 2) As Double
        
    corner(0) = 3#: corner(1) = 3#: corner(2) = 0#
    width = 10
    text = "Hello, World."
    ' Creates a MText object in model space
    Set MTextObj = ThisDrawing.ModelSpace.AddMText(corner, width, text)

    For count = 1 To 9
        MTextObj.AttachmentPoint = count
    
        ' Gets the attachment point of an MText object
        attachPoint = Choose(MTextObj.AttachmentPoint, "TopLeft", "TopCenter", "TopRight", "MiddleLeft", "MiddleCenter", "MiddleRight", "BottomLeft", "BottomCenter", "BottomRight")
    
        ThisDrawing.Regen True
        MsgBox "The attachment point of the MText is now: " & attachPoint, vbInformation, "AttachmentPoint Example"
    Next
End Sub

Visual LISP:

(vl-load-com)
(defun c:Example_AttachmentPoint()
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))

    (setq corner (vlax-3d-point 3 3 0)  
          width 10
          text "Hello, World.")
  
    ;; Creates a MText object in model space
    (setq modelSpace (vla-get-ModelSpace doc))  
    (setq MTextObj (vla-AddMText modelSpace corner width text))
  
    (setq count 1)
    (repeat 9
        (vla-put-AttachmentPoint MTextObj count)

        ;; Gets the attachment point of an MText object
        (cond
            ((= (vla-get-AttachmentPoint MTextObj) 1)(setq attachPoint "TopLeft"))
            ((= (vla-get-AttachmentPoint MTextObj) 2)(setq attachPoint "TopCenter"))
            ((= (vla-get-AttachmentPoint MTextObj) 3)(setq attachPoint "TopRight"))
            ((= (vla-get-AttachmentPoint MTextObj) 4)(setq attachPoint "MiddleLeft"))
            ((= (vla-get-AttachmentPoint MTextObj) 5)(setq attachPoint "MiddleCenter"))
            ((= (vla-get-AttachmentPoint MTextObj) 6)(setq attachPoint "MiddleRight"))
            ((= (vla-get-AttachmentPoint MTextObj) 7)(setq attachPoint "BottomLeft"))
            ((= (vla-get-AttachmentPoint MTextObj) 8)(setq attachPoint "BottomCenter"))
            ((= (vla-get-AttachmentPoint MTextObj) 9)(setq attachPoint "BottomRight"))
	)
    
        (vla-Regen doc :vlax-true)
        (alert (strcat "The attachment point of the MText is now: " attachPoint))
      
        (setq count (1+ count))
    )
)