Revit Text Note formatting codes

Revit Text Note formatting codes

michellem
Advocate Advocate
893 Views
2 Replies
Message 1 of 3

Revit Text Note formatting codes

michellem
Advocate
Advocate

Hello;

I am using the Revit API to import text from MTEXT entities (Autocad) and create properly formatted TextNote objects in Revit.

 

For example, an Mtext string may have an embedded "\P" code in it indicating the start of a new paragraph (hard return). For use in Revit, I replace that code with a "\r". Python code looks like MtextStr = MtextStr.Replace ("\\P", "\r"). This is all well and good.

 

Now on to Newlines. A newline is way of continuing a paragraph on a new line without creating a new paragraph. For example, it can be used to create numbered list with a blank line in it as shown below:

1) Item

 

2) Next Item

 

Such a task can easily be done by a Revit user using shift-key + enter. However Revit API doc says "Newline characters ('\n') are not allowed."  when creating a Text Note. By examining a user created text note with a new line added to it, I see the code "\x0b" embedded in the string.

 

Creating a TextNote using the api, shows that I can indeed create a Text Note with a newline by using the above code. This code however is not documented.

 

So the question is, what are the formatting codes allowed by Revit? I hope to avoid long hours of trial and error if the knowledge I seek is already out there.

 

Sincerely;

Michelle

 

 

0 Likes
Accepted solutions (1)
894 Views
2 Replies
Replies (2)
Message 2 of 3

jeremy_tammik
Alumni
Alumni
Accepted solution

Dear Michelle, 

  

The easiest, fastest and most reliable method to answer such a question is to mostly create the object (or BIM) in question manually through the end user interface and then use RevitLookup and other such Revit database exploration tools to analyse it from an API point of view.

 

In order to see what insights other people dealing with this question have found out and shared, an Internet search can also provide quick results:

  

  

Wowwee. I checked some of the results of the search above and discovered the Revit API FormattedText class:

  

  

The developers guide explains in detail how it can be used:

  

  

Maybe that is closer to what you were looking for. So many options.

  

I hope this helps.

  

Cheers

  

Jeremy

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 3 of 3

michellem
Advocate
Advocate

Hello Jeremy;

 

I should have mentioned that I have seen the documentation on the FormattedText class but I quickly realized it does not fully covered what I need to know. Case in point is the newline example I cited in my initial post. I have not found any documentation of that nor did it turn up in an internet search.

 

So it looks like you are right: I will need to create a variety of test cases and see how Revit handles them from the "api perspective". But I will likely miss one or more possibilities and my program could (will?) crash because of it. Trial and error.

 

Oh well; such is life.

 

Michelle

 

0 Likes