<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Bottom Middle and Top Middle DBText Object not aligning correctly in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/bottom-middle-and-top-middle-dbtext-object-not-aligning/m-p/4794953#M45567</link>
    <description>&lt;P&gt;Hi Guys,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;SPAN&gt;I have a routine that draws a piece of text.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;It works very well except if I use the "Bottom Middle or Top Middle" Alignment.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It draws it but appears as "Middle Middle" alignment.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;After placement I change the Justification with AutoCAD Properties Dialog and set it back again to Bottom Middle and every appears correctly.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Anyone Got any Ideas?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;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&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 05 Feb 2014 06:40:55 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2014-02-05T06:40:55Z</dc:date>
    <item>
      <title>Bottom Middle and Top Middle DBText Object not aligning correctly</title>
      <link>https://forums.autodesk.com/t5/net-forum/bottom-middle-and-top-middle-dbtext-object-not-aligning/m-p/4794953#M45567</link>
      <description>&lt;P&gt;Hi Guys,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;SPAN&gt;I have a routine that draws a piece of text.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;It works very well except if I use the "Bottom Middle or Top Middle" Alignment.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It draws it but appears as "Middle Middle" alignment.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;After placement I change the Justification with AutoCAD Properties Dialog and set it back again to Bottom Middle and every appears correctly.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Anyone Got any Ideas?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;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&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Feb 2014 06:40:55 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/bottom-middle-and-top-middle-dbtext-object-not-aligning/m-p/4794953#M45567</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-02-05T06:40:55Z</dc:date>
    </item>
    <item>
      <title>Re: Bottom Middle and Top Middle DBText Object not aligning correctly</title>
      <link>https://forums.autodesk.com/t5/net-forum/bottom-middle-and-top-middle-dbtext-object-not-aligning/m-p/4795645#M45568</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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&amp;nbsp; an aligment flag.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Gaston Nunez&lt;/P&gt;</description>
      <pubDate>Wed, 05 Feb 2014 13:31:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/bottom-middle-and-top-middle-dbtext-object-not-aligning/m-p/4795645#M45568</guid>
      <dc:creator>hgasty1001</dc:creator>
      <dc:date>2014-02-05T13:31:10Z</dc:date>
    </item>
    <item>
      <title>Re: Bottom Middle and Top Middle DBText Object not aligning correctly</title>
      <link>https://forums.autodesk.com/t5/net-forum/bottom-middle-and-top-middle-dbtext-object-not-aligning/m-p/4798205#M45569</link>
      <description>I have noticed the same thing - and typically write something like:&lt;BR /&gt;&lt;BR /&gt;if(DBText.IsDefaultAlignment)&lt;BR /&gt;DBText.Position = pt;&lt;BR /&gt;else&lt;BR /&gt;DBText.AlignmentPoint = pt;</description>
      <pubDate>Thu, 06 Feb 2014 13:33:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/bottom-middle-and-top-middle-dbtext-object-not-aligning/m-p/4798205#M45569</guid>
      <dc:creator>absStructural</dc:creator>
      <dc:date>2014-02-06T13:33:03Z</dc:date>
    </item>
    <item>
      <title>Re: Bottom Middle and Top Middle DBText Object not aligning correctly</title>
      <link>https://forums.autodesk.com/t5/net-forum/bottom-middle-and-top-middle-dbtext-object-not-aligning/m-p/4800073#M45570</link>
      <description>&lt;P&gt;Thanks guys Ill give it a go and get back to you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Stephan&lt;/P&gt;</description>
      <pubDate>Fri, 07 Feb 2014 01:52:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/bottom-middle-and-top-middle-dbtext-object-not-aligning/m-p/4800073#M45570</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-02-07T01:52:12Z</dc:date>
    </item>
    <item>
      <title>Re: Bottom Middle and Top Middle DBText Object not aligning correctly</title>
      <link>https://forums.autodesk.com/t5/net-forum/bottom-middle-and-top-middle-dbtext-object-not-aligning/m-p/4807131#M45571</link>
      <description>&lt;P&gt;&lt;SPAN&gt;OK Chaps,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Solution found....&amp;nbsp; And what a crappy solution.&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;When placing Text TOP MIDDLE or BOTTOM MIDDLE&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You can use the a&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV class="codeheader"&gt;&lt;SPAN style="line-height: 15px;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;PRE&gt;TextHorizontalMode.TextCenter&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;But&amp;nbsp; the rest use (When refering to the middle of the text&lt;/P&gt;&lt;DIV class="codeheader"&gt;&lt;PRE&gt;TextHorizontalMode.TextMid&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;P&gt;&lt;SPAN&gt;when refering to the middle... GRRRRR&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Stephan&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Feb 2014 04:01:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/bottom-middle-and-top-middle-dbtext-object-not-aligning/m-p/4807131#M45571</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-02-11T04:01:27Z</dc:date>
    </item>
  </channel>
</rss>

