Hi, is there a way to justify text, eg TopLeft, or Center, .... Thanks in advance Frank
Yes...couldn't resist that. Look in the developer guide for the Alignment property and look at the example.
Thanks Ed, I should have searched the help files first. So I came up with this, but the text is placed at (0,0) instead at pTextBuigStaat1. Does anyone know what's wrong? pBuigStaat1(0) = PuntText(0) + 100: pBuigStaat1(1) = PuntText(1) + faktor: pBuigStaat1(2) = 0 Set TextBuigStaat1 = ThisDrawing.ModelSpace.AddText(TextBalkLengte, pTextBuigStaat1, 4) TextBuigStaat1.TextAlingmentPoint = pTextBuigStaat1 TextBuigStaat1.Alignment = acAlignmentCenter Thanks in advance Frank
I have option explicit right on top of the code. What do you mean with "where"? It's just in the code. Frank
This is the difference between the InsertionPoint and TextAlignmentPoint properties. When text is left, fit or aligned, only the InsertionPoint is used. TextAlignmentPoint is set to 0,0,0. When you change to right, for example, you havn't changed the TextAlignmentPoint. It's still 0,0,0. I handle that in a set of text routines called TextUtilities.dvb on the Exchange at augi.com, but the host's server is down right now due to the witty virus. What I do is, store the InsertionPoint, change the alignment. Then while its at 0,0, calculate the difference between the InsertionPoint and the TextAlignmentPoint and then calculate a new TextAlignmentPoint relative to the stored InsertionPoint and assign that new TextAlignmentPoint to the text. The InsertionPoint is automatically adjusted when the TextAlignmentPoint is changed. When you change from right to left, just store the TextAlignmentPoint, change the alignment to left and then set the InsertionPoint to the stored value.
Ed's post is correct if you want to change the alignment without affecting the visible position of the text. If all you want is the text to align at the given insertion point, you simply change the _Alignment_ 1st, then update the _TextAlignmentPoint_ 2nd. Sub Test() Dim pt1(0 To 2) As Double pt1(0) = 6#: pt1(1) = 6# Dim pt2(0 To 2) As Double pt2(0) = 12#: pt2(1) = 12# With ThisDrawing.ModelSpace Dim myCirc1 As AcadCircle Set myCirc1 = .AddCircle(pt1, 1) myCirc1.color = acRed Dim myCirc2 As AcadCircle Set myCirc2 = .AddCircle(pt2, 1) myCirc2.color = acGreen Dim myText As AcadText Set myText = .AddText("Hello, is there anybody out there?", pt1, 0.125) End With myText.Alignment = acAlignmentCenter myText.TextAlignmentPoint = pt1 AcadApplication.ZoomExtents MsgBox "1st text placement" myText.TextAlignmentPoint = pt2 AcadApplication.ZoomExtents MsgBox "2nd text placement" End Sub -- R. Robert Bell This is the difference between the InsertionPoint and TextAlignmentPoint properties. When text is left, fit or aligned, only the InsertionPoint is used. TextAlignmentPoint is set to 0,0,0. When you change to right, for example, you havn't changed the TextAlignmentPoint. It's still 0,0,0. I handle that in a set of text routines called TextUtilities.dvb on the Exchange at augi.com, but the host's server is down right now due to the witty virus. What I do is, store the InsertionPoint, change the alignment. Then while its at 0,0, calculate the difference between the InsertionPoint and the TextAlignmentPoint and then calculate a new TextAlignmentPoint relative to the stored InsertionPoint and assign that new TextAlignmentPoint to the text. The InsertionPoint is automatically adjusted when the TextAlignmentPoint is changed. When you change from right to left, just store the TextAlignmentPoint, change the alignment to left and then set the InsertionPoint to the stored value.