In the example, the Revit.DB.Geometry.XYZ class is used to define a position (with X, Y, Z coordinates) for a text note that the macro will add the text box to the active view of the active document.
In the IDE, use the following code for the method:
public void MyFirstMacroAppCS(){Autodesk.Revit.DB.XYZ baseVec = Application.Create.NewXYZ(1.0, 0.0, 0.0);Autodesk.Revit.DB.XYZ upVec = Application.Create.NewXYZ(0.0, 0.0, 1.0); Autodesk.Revit.DB.XYZ origin = Application.Create.NewXYZ(0.0, 0.0, 0.0);Autodesk.Revit.DB.TextAlignFlags align = Autodesk.Revit.DB.TextAlignFlags.TEF_ALIGN_LEFT | Autodesk.Revit.DB.TextAlignFlags.TEF_ALIGN_TOP;string strText = "My First Macro, App level, C#!"; double lineWidth = 4.0 / 12.0;Autodesk.Revit.DB.View pView = ActiveUIDocument.Document.ActiveView;Autodesk.Revit.DB.Transaction t = new Autodesk.Revit.DB.Transaction(ActiveUIDocument.Document, "NewTextNote");t.Start();ActiveUIDocument.Document.Create.NewTextNote(pView, origin, baseVec, upVec, lineWidth, align, strText);t.Commit();}
Please note that because this application-level macro is written to modify a document, you must begin a transaction (t.Start();) and end the transaction (t.Commit();) for it to run properly.
The macro placed text box