TEXT or MTEXT location

TEXT or MTEXT location

Anonymous
Not applicable
2,589 Views
1 Reply
Message 1 of 2

TEXT or MTEXT location

Anonymous
Not applicable

Hello there, 

 I'm relatively new to AutoCAD vba program. I'm trying to extract the locations of selected texts in my selection set. Is there a way to do it?

0 Likes
2,590 Views
1 Reply
Reply (1)
Message 2 of 2

Anonymous
Not applicable

iterate through each Text object of your SelectionSet object and query its InsertionPoint property to get a three-doubles array with the position of your Text object insertion point:

 

    Dim acTxt As AcadText
    For Each acTxt In ssetObj  '<--| you must be sure that ALL selectionset items are "Text" objects
        With acTxt
            MsgBox "coordinates of text " & .TextString & " are: " _
                   & vbCrLf & vbTab & "x: " & .InsertionPoint(0) _
                   & vbCrLf & vbTab & "y: " & .InsertionPoint(1) _
                   & vbCrLf & vbTab & "z: " & .InsertionPoint(2)
        End With
    Next

 

 

and, to correctly manage InsertionPoint property return array be aware of the following AutoCAD ActiveX Reference Guide pieces of advice:

"This property is read-only except for text whose Alignment property is set to acAlignmentLeft, acAlignmentAligned, or acAlignmentFit. To position text whose justification is other than left, aligned, or fit, use the TextAlignmentPoint property."

 

so if your Text object Alignment property is set to acAlignmentLeft, acAlignmentAligned, or acAlignmentFit, you have to get its TextAlignmentPoint and properly get, in conjunction with InsertionPoint info, its actual placing in the drawing

0 Likes