HorizontalAlignment property example


Sub HorizontalAlignment_Example()
     ' This example creates text and adds it to the drawing using the
     ' AddText method. It then tweaks it's HorizontalAlignment and
     ' VerticalAlignment properties.
     Dim insPt(0 To 2) As Double: insPt(0) = 0: insPt(1) = 9: insPt(2) = 0:
     Dim dHeight As Double: dHeight = 5
     Dim sText As String: sText = "Test string for the AddText method"
     ' Add the Text object
     Dim oText As AcadText
     Set oText = ThisDrawing.ModelSpace.AddText(sText, insPt, dHeight)
     ReAlign oText, acHorizontalAlignmentLeft, acVerticalAlignmentBaseline
     ReAlign oText, acHorizontalAlignmentCenter, acVerticalAlignmentBaseline
     ReAlign oText, acHorizontalAlignmentRight, acVerticalAlignmentBaseline
     ReAlign oText, acHorizontalAlignmentLeft, acVerticalAlignmentBottom
     ReAlign oText, acHorizontalAlignmentLeft, acVerticalAlignmentMiddle
     ReAlign oText, acHorizontalAlignmentLeft, acVerticalAlignmentTop
End Sub
Private Sub ReAlign(tt As AcadText, aH As AcHorizontalAlignment, aV As AcVerticalAlignment)
    tt.HorizontalAlignment = aH
    tt.VerticalAlignment = aV
    tt.Update
    Dim sBuf As String
    sBuf = "HorizontalAlignment property is: " & tt.HorizontalAlignment
    sBuf = sBuf & Chr(13) & "VerticalAlignment property is: " & tt.VerticalAlignment
    MsgBox sBuf
End Sub

© Bricsys NV. All rights reserved.