V8i VBA text wrapping

I'm trying to find a way to add text nodes that will wrap based on a specified line length using VBA. I would also like to preserve the ability to use handles to manually decrease the text wrapping (i.e. make text lines longer), so I don't want to split the string into multiple parts and add multiple lines because this will only allow you to increase the wrapping (make lines shorter). I have tried using ActiveSettings.TextStyle.NodeLineLength which appears to have no effect (intentionally commented out below), and oNode.LineLength which causes every word to be wrapped and then will not allow the text wrap to be decreased beyond the linelength using handles. Is there some other way? Here is some code I have been using as a test. Sorry, I don't know how to post code so it looks right.



Sub TextNodeWrapTest()
 Dim oNode As TextNodeElement

 With ActiveSettings.TextStyle
  .Width = 1
  .Height = 1
  .NodeJustification = msdTextJustificationLeftTop
 '.NodeLineLength = 10
  .NodeLineSpacing = 1
  .NodeLineSpacingType = msdTextNodeLineSpacingTypeExact
 End With

 Set oNode = CreateTextNodeElement1(Nothing, Point3dFromXYZ(0, 0, 0), Matrix3dIdentity)
 oNode.AddTextLine "THIS IS A STRING OF TEXT THAT I WANT TO WRAP"
 oNode.LineLength = 15
 ActiveModelReference.AddElement oNode

'Debug.Print "NodeLineLength = " & ActiveSettings.TextStyle.NodeLineLength
 Debug.Print "LineLength = " & oNode.LineLength

End Sub



  • Unknown said:
    I have tried using ActiveSettings.TextStyle.NodeLineLength oNode.LineLength which causes every word to be wrapped and then will not allow the text wrap to be decreased beyond the linelength

    I ran your code and it seemed that I could resize your text.  I notice that the mid-side handles act to scale the entire text node.  The corner handles have the effect of modifying the line length and so adjust the number of text elements in the text node.  I don't see what isn't working for you.

    You may want to investigate using text styles as a way of specifying text formatting.

     
    Regards, Jon Summers
    LA Solutions

  • Unknown said:
    I notice that the mid-side handles act to scale the entire text node. 

    Yes, I get the same and that is proper behavior. No issue there.

    Unknown said:
    I ran your code and it seemed that I could resize your text. 

    I can "resize" also, but I cannot increase the wrapped line length greater than what is specified by LineLength (i.e. when LineLength is set to 15 I cannot increase a text line to greater than 15 characters using handle wrapping). That is something I would also expect, but I am looking for a way to avoid this behavior (i.e. text handles are able to increase line length beyond value used to initially place the text).

    Unknown said:
    I don't see what isn't working for you.

    Setting NodeLineLength has no effect (text is placed as a single line), and setting LineLength results in text that is placed with every word wrapped (as shown in attached image).  So I either get text that is not wrapped at all or every word wrapped.

    Unknown said:
    You may want to investigate using text styles as a way of specifying text formatting.

    LineLength is a TextNodeElement  property. NodeLineLength is a text style property and when I try to use it (code below) it has no effect. I cannot find any other text style properties that control the line length. What I really want is to be able to set the wrap length but it does not appear that is possible??

    
    Sub TextNodeWrapTest()
     Dim oNode As TextNodeElement
    
     With ActiveSettings.TextStyle
      .Width = 1
      .Height = 1
      .NodeJustification = msdTextJustificationLeftTop
      .NodeLineLength = 10
      .NodeLineSpacing = 1
      .NodeLineSpacingType = msdTextNodeLineSpacingTypeExact
     End With
    
     Set oNode = CreateTextNodeElement1(Nothing, Point3dFromXYZ(0, 0, 0), Matrix3dIdentity)
     oNode.AddTextLine "THIS IS A STRING OF TEXT THAT I WANT TO WRAP"
     ActiveModelReference.AddElement oNode
    
     Debug.Print "NodeLineLength = " & ActiveSettings.TextStyle.NodeLineLength
    End Sub