Trouble with AttachmentPoint.TopCenter

Trouble with AttachmentPoint.TopCenter

GTVic
Advisor Advisor
648 Views
3 Replies
Message 1 of 4

Trouble with AttachmentPoint.TopCenter

GTVic
Advisor
Advisor
When I create DBText with a TopCenter alignment, the text comes out "Aligned" with a Height of 0 and Angle of 0. Any other value for the attachment point seems to work fine.

tsTable = CType(Trans.GetObject(AcadDoc.Database.TextStyleTableId, OpenMode.ForWrite), TextStyleTable)
Align = AttachmentPoint.TopCenter
TextEnt = New DBText
TextEnt.SetDatabaseDefaults()
TextEnt.TextString = TextString
TextEnt.Position = New Point3d(InsPoint)
TextEnt.Justify = Align
If Align <> AttachmentPoint.BaseLeft Then TextEnt.AlignmentPoint = New Point3d(InsPoint)
TextEnt.Height = Height
TextEnt.ColorIndex = Color
TextEnt.Rotation = Angle
TextEnt.TextStyle = tsTable(Style)
TextEnt.Layer = Layer
btr = Trans.GetObject(AcadDoc.Database.CurrentSpaceId, OpenMode.ForWrite)
btr.AppendEntity(TextEnt)
Trans.AddNewlyCreatedDBObject(TextEnt, True)
Trans.Commit()
0 Likes
649 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable
I've seen that, too. You can set the attribute's VerticalMode and HorizontalMode separately to achieve a TopCenter justification.

-drg
0 Likes
Message 3 of 4

GTVic
Advisor
Advisor
Thanks, I'll give that a try.
0 Likes
Message 4 of 4

GTVic
Advisor
Advisor
That worked, here is the code I used:
{code}
If Align = AttachmentPoint.BaseLeft Then
TextEnt.Justify = Align
ElseIf Align = AttachmentPoint.TopCenter Then
TextEnt.VerticalMode = TextVerticalMode.TextTop
TextEnt.HorizontalMode = TextHorizontalMode.TextCenter
TextEnt.AlignmentPoint = New Point3d(InsPoint)
Else
TextEnt.Justify = Align
TextEnt.AlignmentPoint = New Point3d(InsPoint)
End If
{code}
0 Likes