Returns an object that contains text and associated formatting of this note.
Namespace: Autodesk.Revit.DB
Assembly: RevitAPI (in RevitAPI.dll) Version: 17.0.0.0 (17.0.1090.0)
Since: 2017
Syntax
C# |
---|
|
Visual Basic |
---|
|
Visual C++ |
---|
|
Return Value
The object that contains the text and associated formatting of of the text in this text note.Remarks
The returned object is not attached to the text note and modifying it will not modify the contents of the text note. After changes are made to the FormattedText, use SetFormattedText(FormattedText) apply those changes to the TextNote.
Examples

#region Autodesk.Revit.DB.FormattedText.SetListType(Autodesk.Revit.DB.TextRange, Autodesk.Revit.DB.ListType)
#region Autodesk.Revit.DB.FormattedText.AsTextRange()
public void AppendText(TextNote textNote)
{
FormattedText formatText = textNote.GetFormattedText();
TextRange range = formatText.AsTextRange();
range.Start = range.End - 1;
// set Length to 0 to insert
range.Length = 0;
string someNewText = "\rThis is a new paragraph\vThis is a new line without a paragraph break\r";
formatText.SetPlainText(range, someNewText);
// get range for entire text
range = formatText.AsTextRange();
range.Start = range.End - 1;
range.Length = 0;
string someListText = "\rBulleted List item 1\rItem 2\vSecond line for Item 2\rThird bullet point";
formatText.SetPlainText(range, someListText);
range.Start++;
range.Length = someListText.Length;
formatText.SetListType(range, ListType.Bullet);
if (formatText.GetAllCapsStatus(range) != FormatStatus.None)
{
formatText.SetAllCapsStatus(range, false);
}
textNote.SetFormattedText(formatText);
}
#endregion
#endregion

#Region "Autodesk.Revit.DB.FormattedText.SetListType(Autodesk.Revit.DB.TextRange, Autodesk.Revit.DB.ListType)"
#Region "Autodesk.Revit.DB.FormattedText.AsTextRange()"
Public Sub AppendText(textNote As TextNote)
Dim formatText As FormattedText = textNote.GetFormattedText()
Dim range As TextRange = formatText.AsTextRange()
range.Start = range.[End] - 1
' set Length to 0 to insert
range.Length = 0
Dim someNewText As String = vbCr & "This is a new paragraph" & vbVerticalTab & "This is a new line without a paragraph break" & vbCr
formatText.SetPlainText(range, someNewText)
' get range for entire text
range = formatText.AsTextRange()
range.Start = range.[End] - 1
range.Length = 0
Dim someListText As String = vbCr & "Bulleted List item 1" & vbCr & "Item 2" & vbVerticalTab & "Second line for Item 2" & vbCr & "Third bullet point"
formatText.SetPlainText(range, someListText)
range.Start += 1
range.Length = someListText.Length
formatText.SetListType(range, ListType.Bullet)
If formatText.GetAllCapsStatus(range) <> FormatStatus.None Then
formatText.SetAllCapsStatus(range, False)
End If
textNote.SetFormattedText(formatText)
End Sub
#End Region
#End Region