How to create text element with multi line text?

How do I send a text string to microstation and get the text onto multiple lines as one text element?  I have tried using the chr function to place a line break in the text string.  The text will show up something like this when first created "Line1*Line2".  If I go to edit the text to see what happened to the text and then do nothing other than look at it and then close the text editor the text will then wrap the text to the second line.  Any ideas?

field$ = LineArray(3)
textstring$ = ""
Do While (InStr(1, field$, "~Chr(10)~") > 0)
textstring$ = textstring$ + Left$(field$, InStr(1, field$, "~Chr(10)~") - 2) + Chr$(10)
field$ = Right$(field$, Len(field$) - InStr(1, field$, "~Chr(10)~") - 9)
Loop
field$ = textstring$ + field$

Set tEl = CreateTextElement1(Nothing, field$, point, Matrix3dIdentity)

  • Hi, use TextNodeElement instead. The difference between a TextElement and a TextNodeElement is that a text element comprises a single line of text, while a text node element can comprise multiple lines of text. A text node element is a ComplexElement whose sub-elements are text elements.

    Dim tn As TextNodeElement
    Set tn = CreateTextNodeElement2(Nothing, Point3dZero, Matrix3dIdentity, False)
    tn.AddTextLine "Hello"
    tn.AddTextLine "World"
    ActiveModelReference.AddElement tn
    tn.Redraw
     

     HTH

     

  • Thanks for the information DanPaul!!  Please help me with one other question with TextNodeElement.  How do I change the font of a TextNodeElement?  It is probably really simple, but I can't find it anywhere.
  • Sub main()

        Dim tn As TextNodeElement
        Dim ee As ElementEnumerator
        Dim txtElm As TextElement
        Dim i As Long
        
        Set tn = CreateTextNodeElement2(Nothing, Point3dZero, Matrix3dIdentity, False)
        tn.AddTextLine "Hello"
        tn.AddTextLine "World"
            
        ActiveModelReference.AddElement tn ' Unfortunately has to be added...
        
        Set ee = tn.GetSubElements
        
        While ee.MoveNext
            Set txtElm = ee.Current.AsTextElement
            txtElm.Color = Rnd(1) * 8
            Set txtElm.TextStyle.Font = ActiveDesignFile.Fonts.Item(Rnd(1) * ActiveDesignFile.Fonts.Count)
            txtElm.Rewrite
        Wend


    End Sub
     
  • Thanks for the help!!!  I was thinking about going that direction but I couldn't figure it out just yet.