Hi Guys,
I have a routine that draws a piece of text.
It works very well except if I use the "Bottom Middle or Top Middle" Alignment.
It draws it but appears as "Middle Middle" alignment.
After placement I change the Justification with AutoCAD Properties Dialog and set it back again to Bottom Middle and every appears correctly.
Anyone Got any Ideas?
Tr = CurDb.TransactionManager.StartTransaction() Try Using Tr Dim BlkTable As BlockTable = Tr.GetObject(CurDb.BlockTableId, OpenMode.ForRead) Dim BlkRableRec As BlockTableRecord = Tr.GetObject(BlkTable(BlockTableRecord.PaperSpace), OpenMode.ForWrite) Dim NewText As DBText = New DBText NewText.SetDatabaseDefaults() NewText.Position = New Point3d(InsertPoint.asArray) NewText.Height = Data.TextHeight NewText.TextString = Data.LabelPrefix + RetData + Data.LabelSuffix NewText.Rotation = Data.ActualAngle Dim AlignmentFlagSet As Boolean = False Select Case Data.TextAlignment Case "Top_Left" NewText.HorizontalMode = TextHorizontalMode.TextLeft NewText.VerticalMode = TextVerticalMode.TextTop AlignmentFlagSet = True Case "Top_Middle" NewText.HorizontalMode = TextHorizontalMode.TextMid NewText.VerticalMode = TextVerticalMode.TextTop AlignmentFlagSet = True Case "Top_Right" NewText.HorizontalMode = TextHorizontalMode.TextRight NewText.VerticalMode = TextVerticalMode.TextTop AlignmentFlagSet = True Case "Middle_Left" NewText.HorizontalMode = TextHorizontalMode.TextLeft NewText.VerticalMode = TextVerticalMode.TextVerticalMid AlignmentFlagSet = True Case "Middle_Middle" NewText.HorizontalMode = TextHorizontalMode.TextMid NewText.VerticalMode = TextVerticalMode.TextVerticalMid AlignmentFlagSet = True Case "Middle_Right" NewText.HorizontalMode = TextHorizontalMode.TextRight NewText.VerticalMode = TextVerticalMode.TextVerticalMid AlignmentFlagSet = True Case "Bottom_Left" NewText.HorizontalMode = TextHorizontalMode.TextLeft NewText.VerticalMode = TextVerticalMode.TextBottom AlignmentFlagSet = True Case "Bottom_Middle" NewText.HorizontalMode = TextHorizontalMode.TextMid NewText.VerticalMode = TextVerticalMode.TextBottom AlignmentFlagSet = True Case "Bottom_Right" NewText.HorizontalMode = TextHorizontalMode.TextRight NewText.VerticalMode = TextVerticalMode.TextBottom AlignmentFlagSet = True End Select If AlignmentFlagSet = True Then NewText.AlignmentPoint = New Point3d(AlignPoint.asArray) Else Ed.WriteMessage("Alignment Point Skipped!" + vbCrLf) End If 'added to fix alignment issue 'Dim WDB As Database = HostApplicationServices.WorkingDatabase 'HostApplicationServices.WorkingDatabase = CurDb 'NewText.AdjustAlignment(CurDb) 'HostApplicationServices.WorkingDatabase = WDB NewText.TextStyleId = GetTextStyleID(Data.TextStyle) NewText.LayerId = GetLayerID(Data.LabelLayer) BlkRableRec.AppendEntity(NewText) Tr.AddNewlyCreatedDBObject(NewText, True) Tr.Commit() End Using Catch ex As System.Exception 'Something Ed.WriteMessage(ex.Message) Finally End Try
Solved! Go to Solution.
Hi,
Not sure, but i think that if the text is aligned you have to set only the AlignmentPoint, in other words, delete the line with NewText.Position=..., and set its position only if the text has NOT an aligment flag.
Gaston Nunez
OK Chaps,
Solution found.... And what a crappy solution.
When placing Text TOP MIDDLE or BOTTOM MIDDLE
You can use the a
TextHorizontalMode.TextCenter
But the rest use (When refering to the middle of the text
TextHorizontalMode.TextMid
when refering to the middle... GRRRRR
Stephan