justify text

Discussion in 'AutoCAD' started by frank roegiers, Apr 8, 2004.

  1. Hi,

    is there a way to justify text, eg TopLeft, or Center, ....


    Thanks in advance


    Frank
     
    frank roegiers, Apr 8, 2004
    #1
  2. frank roegiers

    Ed Jobe Guest

    Yes...couldn't resist that. :) Look in the developer guide for the
    Alignment property and look at the example.
     
    Ed Jobe, Apr 8, 2004
    #2
  3. 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
     
    frank roegiers, Apr 9, 2004
    #3
  4. Where are you setting pTextBuigStaat1 ???

    Option Explicit might help you avoid some of these errors.
     
    Jorge Jimenez, Apr 9, 2004
    #4
  5. I have option explicit right on top of the code.
    What do you mean with "where"? It's just in the code.

    Frank
     
    frank roegiers, Apr 9, 2004
    #5
  6. frank roegiers

    Ed Jobe Guest

    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 Jobe, Apr 9, 2004
    #6
  7. 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.
     
    R. Robert Bell, Apr 9, 2004
    #7
  8. Place a breakpoint here
    pTextBuigStaat1, 4)

    and watch pTextBuigStaat1 value.
     
    Jorge Jimenez, Apr 9, 2004
    #8
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.