TextAlignmentPoint Property (ActiveX)

Specifies the alignment point for text and attributes.

Supported platforms: Windows only

Signature

VBA:

object.TextAlignmentPoint
object

Type: Attribute, AttributeReference, Text

The object this property applies to.

Property Value

Read-only: No

Type: Variant (three-element array of doubles)

A 3D WCS coordinate representing the alignment point of the object.

Remarks

Text: This property will be reset to 0, 0, 0 and will become read-only when the Alignment property is set to acAlignmentLeft. To position text whose justification is left, fit, or aligned, use the InsertionPoint property.

Examples

VBA:

Sub Example_TextAlignmentPoint()
    ' This example creates a text object in model space.
    ' It then changes the TextAlignmentPoint and HorizontalAlignment
    ' properties of the text object.

    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) = 3: insertionPoint(1) = 3: insertionPoint(2) = 0
    height = 0.5
    
    ' Create the text object in model space
    Set textObj = ThisDrawing.ModelSpace.AddText(textString, insertionPoint, height)
    ZoomAll
    MsgBox "The TextAlignmentPoint is set to the default " & _
           textObj.TextAlignmentPoint(0) & ", " & _
           textObj.TextAlignmentPoint(1) & ", " & _
           textObj.TextAlignmentPoint(2), vbInformation, _
           "TextAlignmentPoint Example"
    
    ' Change the value of the HorizontalAlignment and
    ' TextAlignmentPoint properties.
    ' Note that the HorizontalAlignment property must be changed first,
    ' and to a value that requires the TextAlignmentPoint, before the
    ' TextAlignmentPoint property will allow a value to be set.
    Dim alignmentPoint(0 To 2) As Double
    alignmentPoint(0) = 5: alignmentPoint(1) = 3: alignmentPoint(2) = 0
    textObj.HorizontalAlignment = acHorizontalAlignmentFit
    textObj.TextAlignmentPoint = alignmentPoint
    ZoomAll
    MsgBox "The TextAlignmentPoint is set to " & _
           textObj.TextAlignmentPoint(0) & ", " & _
           textObj.TextAlignmentPoint(1) & ", " & _
           textObj.TextAlignmentPoint(2) & vbCrLf & _
           "The HorizontalAlignment is set to acHorizontalAlignmentFit", _
           vbInformation, "TextAlignmentPoint Example"
    
End Sub

Visual LISP:

(vl-load-com)
(defun c:Example_TextAlignmentPoint()
    ;; This example creates a text object in model space.
    ;; It then changes the TextAlignmentPoint and HorizontalAlignment
    ;; properties of the text object.
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))
    
    ;; Define the text object
    (setq insertionPoint (vlax-3d-point 3 3 0)  
          textString "Hello, World."
          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)

    (setq alignmentPoint (vlax-variant-value (vla-get-TextAlignmentPoint textObj)))
    (alert (strcat "The TextAlignmentPoint is set to the default " (rtos (vlax-safearray-get-element alignmentPoint 0) 2) ", "
                                                                   (rtos (vlax-safearray-get-element alignmentPoint 1) 2) ", "
                                                                   (rtos (vlax-safearray-get-element alignmentPoint 2) 2)))
    
    ;; Change the value of the HorizontalAlignment and
    ;; TextAlignmentPoint properties.
    ;; Note that the HorizontalAlignment property must be changed first,
    ;; and to a value that requires the TextAlignmentPoint, before the
    ;; TextAlignmentPoint property will allow a value to be set.
    (setq alignmentPoint (vlax-3d-point 5 3 0))
    (vla-put-Alignment textObj acHorizontalAlignmentFit)
    (vla-put-TextAlignmentPoint textObj alignmentPoint)
    (vla-ZoomAll acadObj)

    (setq alignmentPoint (vlax-variant-value (vla-get-TextAlignmentPoint textObj)))
    (alert (strcat "The TextAlignmentPoint is set to " (rtos (vlax-safearray-get-element alignmentPoint 0) 2) ", "
                                                       (rtos (vlax-safearray-get-element alignmentPoint 1) 2) ", "
                                                       (rtos (vlax-safearray-get-element alignmentPoint 2) 2)))
)