SetFormattedText Method


Sets the text and associated formatting of the text of in this text note with a given FormattedText object.

Namespace: Autodesk.Revit.DB
Assembly: RevitAPI (in RevitAPI.dll) Version: 22.0.0.0 (22.1.0.0)
Since: 2017

Syntax

C#
public void SetFormattedText(
	FormattedText formattedText
)
Visual Basic
Public Sub SetFormattedText ( _
	formattedText As FormattedText _
)
Visual C++
public:
void SetFormattedText(
	FormattedText^ formattedText
)

Parameters

formattedText
Type: Autodesk.Revit.DB FormattedText
The FormattedText object containing the text and associated formatting of the text.

Examples

Copy C#
#region Autodesk.Revit.DB.FormattedText
public void FormatText(TextNote textNote)
{
    // TextNote created with "New sample text"
    FormattedText formatText = textNote.GetFormattedText();

    // italicize "New"
    TextRange range = new TextRange(0, 3);
    formatText.SetItalicStatus(range, true);

    // make "sample" bold
    range = formatText.Find("sample", 0, false, true);
    if (range.Length > 0)
        formatText.SetBoldStatus(range, true);

    // make "text" underlined
    range = formatText.Find("text", 0, false, true);
    if (range.Length > 0)
        formatText.SetUnderlineStatus(range, true);

    // make all text uppercase
    formatText.SetAllCapsStatus(true);

    textNote.SetFormattedText(formatText);
}
#endregion
Copy VB.NET
#Region "Autodesk.Revit.DB.FormattedText"
        Public Sub FormatText(textNote As TextNote)
            ' TextNote created with "New sample text"
            Dim formatText__1 As FormattedText = textNote.GetFormattedText()

            ' italicize "New"
            Dim range As New TextRange(0, 3)
            formatText__1.SetItalicStatus(range, True)

            ' make "sample" bold
            range = formatText__1.Find("sample", 0, False, True)
            If range.Length > 0 Then
                formatText__1.SetBoldStatus(range, True)
            End If

            ' make "text" underlined
            range = formatText__1.Find("text", 0, False, True)
            If range.Length > 0 Then
                formatText__1.SetUnderlineStatus(range, True)
            End If

            ' make all text uppercase
            formatText__1.SetAllCapsStatus(True)

            textNote.SetFormattedText(formatText__1)
        End Sub
#End Region

Exceptions

Exception Condition
Autodesk.Revit.Exceptions ArgumentNullException A non-optional argument was null

See Also

ArchiLabs Desktop

Put AI to work inside Revit.

Give Desktop your instructions and project files to build Revit families, update model elements, and create views and schedules. Works directly in Revit and AutoCAD.

Explore Desktop →