Namespace:
Autodesk.Revit.DB
Assembly:
RevitAPI
(in RevitAPI.dll) Version: 17.0.0.0 (17.0.484.0)
Since:
2017
Syntax
C# |
---|
|
Visual Basic |
---|
|
Visual C++ |
---|
|
Remarks
An instance of FormattedText can be obtained from a TextNote (See TextNote.GetFormattedText() ) or from a TextNode (See TextNode.GetFormattedText() )
It is also possible to create a new instance of FormattedText and assign it to a TextNote (See TextNote.SetFormattedText() ) This will result in a TextNote with text with the specified formatting applied
Formatted text can be used to:
- Create formatted text for a new TextNote
- Edit, Find and Replace text in an existing TextNote
- Modify formatting of text in an existing TextNote
- Or query the text and formatting a TextNote or a TextNode
Formatted text can be populated with plain text by using its constructor FormattedText(String) that takes a string, or by using the SetPlainText(String) method.
In addition, selected ranges of text can be added, removed, or replaced with the SetPlainText(TextRange, String) method by specifying a TextRange .
Use the Find(String, Int32, Boolean, Boolean) method to find the location of existing text.
Formatted text can have up to 30,000 characters. All characters, except the linefeed character ('\n'), are allowed. This means that you should not use the 'Environment.NewLine' property, since that includes a linefeed character. Use the carriage return character ('\r') to terminate a paragraph. And use a vertical tab character ('\v') to create a new line without terminating the paragraph.
Formatted text allows for individual characters to be formatted. The following formatting can be applied.
- Bold
- Italic
- Underline
- Superscript/Subscript
- All Caps
Use GetBoldStatus(TextRange) ) , GetItalicStatus(TextRange) ) , GetUnderlineStatus(TextRange) ) , GetSuperscriptStatus(TextRange) ) , GetSubscriptStatus(TextRange) ) , or GetAllCapsStatus(TextRange) ) to get the character formatting of a range of text.
Text can be broken up in paragraphs. Paragraphs are terminated by a carriage return character ('\r').
Each paragraph can be indented several levels deep. For each additional level the indentation increments by one tab size. The total indentation is the product of a tab size and the indent level. Use SetIndentLevel(TextRange, Int32) to set the level of indenting up to a maximum indent level that can be obtained from GetMaximumIndentLevel Use GetIndentLevel(TextRange) to find the indent level of a given range of text.
Note that the tab size is determined by the object that will contain the FormattedText.
In the case of a TextNote the tab size is a property of the TextNoteType returned from TextNote.TextNoteType . The tab size can be found by calling the Parameter Guid with TEXT_TAB_SIZE on the TextNoteType obtained from the TextNote
In the case of a TextNode the tab size can be obtained from its TabSize property
Formatted text can also be used to create numbered or bulleted paragraphs with the SetListType(TextRange, ListType) method.
The following ListType options are available:
Paragraphs with a ListType other than None are considered to be 'list' paragraphs. Consecutive list paragraphs with the same indentation level are treated as part of the same list. A list ends when a list paragraph is followed by- a paragraph that has None
- or a list paragraph that has a lower indentation level, i.e. is indented less. (See GetIndentLevel(TextRange) )
FormattedText will keep lists consistent. That means that list paragraphs will automatically get sequential numbers or letters. It also means that if the list type of one of the paragraphs in a list is changed then that change is propagated to all the paragraphs in that list. Note that this will not affect the list type of any nested sub-lists.
Use a vertical tab character ('\v') to insert a line without a bullet or number. Since this does not end the paragraph this will allow the list to continue to the next paragraph.