Text |
Namespace: Autodesk.Revit.DB
Assembly: RevitAPI (in RevitAPI.dll) Version: 25.0.0.0 (25.0.0.0)
public static TextNote Create( Document document, ElementId viewId, XYZ position, double width, string text, TextNoteOptions options )
Public Shared Function Create ( document As Document, viewId As ElementId, position As XYZ, width As Double, text As String, options As TextNoteOptions ) As TextNote
public: static TextNote^ Create( Document^ document, ElementId^ viewId, XYZ^ position, double width, String^ text, TextNoteOptions^ options )
static member Create : document : Document * viewId : ElementId * position : XYZ * width : float * text : string * options : TextNoteOptions -> TextNote
Parameters
- document Document
- A valid Revit document that is currently modifiable (i.e. with an open transaction).
- viewId ElementId
- Id of the graphic view in which the note is to be created.
- position XYZ
-
A model position of the new note.
Note that the position's relation to the text's bounding box depends on the requested text alignment (set via the Options argument). It will be the box' top-left corner for a left-aligned text, the top-right corner for a right-aligned text, and middle-top point if the text is to be centered.
- width Double
- Width [ft] of the text in paper space (i.e. as it is measured when printed.) If a line of text is longer than the given specified Width, the text will be automatically wrapped. If a a zero Width is supplied then this method will create an unwrapped text note element.
- text String
- Text to populate the text note with.
- options TextNoteOptions
- Options to control behavior and appearance of the text note.
Return Value
TextNoteThe newly created text note.

Exception | Condition |
---|---|
ArgumentException | The document is a family that cannot contain text notes. -or- The viewId does not represent a valid graphic view element in the given document. -or- The options structure does not contain a valid text type to use for a new text note in the given document. -or- A valid point must not be father then 10 miles (approx. 16 km) from the origin. -or- The given width is not valid. A valid value must be within the range returned by static methods GetMinimumWidthLimit and GetMaximumWidthLimit. |
ArgumentNullException | A non-optional argument was null |

As a view-specific element the text note will be visible only in the specified view.
The new text note will be created using the give text type, which defines the style. The currently default style can be obtained from the Document.GetDefaultElementTypeId method.

#region Autodesk.Revit.DB.TextElement.GetMinimumAllowedWidth(Autodesk.Revit.DB.Document, Autodesk.Revit.DB.ElementId) public TextNote AddNewTextNote(UIDocument uiDoc) { Document doc = uiDoc.Document; XYZ textLoc = uiDoc.Selection.PickPoint("Pick a point for sample text."); ElementId defaultTextTypeId = doc.GetDefaultElementTypeId(ElementTypeGroup.TextNoteType); double noteWidth = .2; // make sure note width works for the text type double minWidth = TextNote.GetMinimumAllowedWidth(doc, defaultTextTypeId); double maxWidth = TextNote.GetMaximumAllowedWidth(doc, defaultTextTypeId); if (noteWidth < minWidth) { noteWidth = minWidth; } else if (noteWidth > maxWidth) { noteWidth = maxWidth; } TextNoteOptions opts = new TextNoteOptions(defaultTextTypeId); opts.HorizontalAlignment = HorizontalTextAlignment.Left; opts.Rotation = Math.PI / 4; TextNote textNote = TextNote.Create(doc, doc.ActiveView.Id, textLoc, noteWidth, "New sample text", opts); return textNote; } #endregion
#Region "Autodesk.Revit.DB.TextElement.GetMinimumAllowedWidth(Autodesk.Revit.DB.Document, Autodesk.Revit.DB.ElementId)" Public Function AddNewTextNote(uiDoc As UIDocument) As TextNote Dim doc As Document = uiDoc.Document Dim textLoc As XYZ = uiDoc.Selection.PickPoint("Pick a point for sample text.") Dim defaultTextTypeId As ElementId = doc.GetDefaultElementTypeId(ElementTypeGroup.TextNoteType) Dim noteWidth As Double = 0.2 ' make sure note width works for the text type Dim minWidth As Double = TextNote.GetMinimumAllowedWidth(doc, defaultTextTypeId) Dim maxWidth As Double = TextNote.GetMaximumAllowedWidth(doc, defaultTextTypeId) If noteWidth < minWidth Then noteWidth = minWidth ElseIf noteWidth > maxWidth Then noteWidth = maxWidth End If Dim opts As New TextNoteOptions(defaultTextTypeId) opts.HorizontalAlignment = HorizontalTextAlignment.Left opts.Rotation = Math.PI / 4 Dim textNote__1 As TextNote = TextNote.Create(doc, doc.ActiveView.Id, textLoc, noteWidth, "New sample text", opts) Return textNote__1 End Function #End Region
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.