FormattedText: coding Soft vs Hard Carriage Returns

FormattedText: coding Soft vs Hard Carriage Returns

Josh_Hunt
Advocate Advocate
674 Views
3 Replies
Message 1 of 4

FormattedText: coding Soft vs Hard Carriage Returns

Josh_Hunt
Advocate
Advocate
How are soft returns (user pressing Shift+Enter) and hard returns (user pressing Enter) stored/coded for drawing text?

EXAMPLE: this code below will replace all the soft returns with hard returns. However, nothing should have changed.
GeneralNote.FormattedText = GeneralNote.FormattedText
I have also attached a drawing with an iLogic rule to prove the point. It writes the FormattedText of both notes to a local text file before they are changed. The exported text is identical.
Josh Hunt
0 Likes
Accepted solutions (1)
675 Views
3 Replies
Replies (3)
Message 2 of 4

WCrihfield
Mentor
Mentor
Accepted solution

Hi @Josh_Hunt.  Inventor's use of XML in their FormattedText Strings is something that hasn't been documented very well.  There is one main link here, but that doesn't really do very much to help in many cases.  I often refer to other places online like w3.org or w3schools.com for further knowledge about doing things with XML.  Inventor doesn't seem to preserve some 'white space' types/instances by generating types of special characters or XML elements in their places.  I know that within the FormattedText, when you use any of these Constants (vbCr, vbLf, vbCrLf, vbNewLine) between quoted String segments, it simply injects the same "<Br/>" element in its place, which, as you know, simply wraps any following text to the next line.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 3 of 4

WCrihfield
Mentor
Mentor

Also, you may have already seen this technique before, but I often use this when dealing with FormattedText scenarios.  So when the note is complicated (like most are in this case), I will usually create the note manually, just the way I want it first.  Then I use this quick little snippet of code, which will allow me to manually select the note I want to inspect, then it uses an InputBox (instead of a MessageBox.Show or MsgBox) to display the FormattedText to me, so that I can easily select it, then post it back into my code, if needed.  This is a little quicker and neater than the text file route.  I put the result into the 'default response' section of the InputBox's input variables, instead of into its 'Prompt' section, so that it will be select-able.

Dim oDNote As DrawingNote = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingNoteFilter, "Select a drawing note.")
a = InputBox("", "FormattedText", oDNote.FormattedText)

I use the DrawingNote type variable, because it is the base class for most of the other types of notes, which makes it work for all the other derived types under it.

 

If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click (LIKE or KUDOS) 👍.

If you want and have time, I would appreciate your Vote(s) for My IDEAS 💡or you can Explore My CONTRIBUTIONS

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 4 of 4

Josh_Hunt
Advocate
Advocate

@WCrihfield Thank you. I was hoping for a slightly cleaner answer about how soft returns are stored so I can reliably change existing formatted text.

 

I think (vbCr, vbLf, vbCrLf, vbNewLine) should work for what I'm building (new text from code).

Josh Hunt
0 Likes