Example:Application-Level Macro in C#
In the IDE, in the main window for the ThisApplication.cs source code, you can now enter your macro code.
For example, here is the
MyFirstMacroAppCS
method in C#:
public void MyFirstMacroAppCS()
{
Autodesk.Revit.Geometry.XYZ baseVec = this.Create.NewXYZ(1.0, 0.0, 0.0);
Autodesk.Revit.Geometry.XYZ upVec = this.Create.NewXYZ(0.0, 0.0, 1.0);
Autodesk.Revit.Geometry.XYZ origin = this.Create.NewXYZ(0.0, 0.0, 0.0);
Autodesk.Revit.Enums.TextAlignFlags align =
Autodesk.Revit.Enums.TextAlignFlags.TEF_ALIGN_LEFT |
Autodesk.Revit.Enums.TextAlignFlags.TEF_ALIGN_TOP;
string strText = "My First Macro, App level, C#!";
double lineWidth = 4.0 / 12.0;
View pView = this.ActiveDocument.ActiveView;
this.ActiveDocument.Create.NewTextNote(pView, origin, baseVec, upVec, lineWidth, align,
strText);
}
In the example, the Revit API Geometry.XYZ class is used to define a position (with X, Y, Z coordinates) for
a Text Note that the macro will add to the active view of the active document.
For now, you can skip any implementation of the startup and shutdown methods.
In your Revit VSTA IDE session, you can copy and paste the code snippet shown previously and insert it
into your macro's method. After pasting the code from this documentation, check that no special characters
were added.
Build Macros in the Revit VSTA IDE
In the Revit VSTA IDE, select the Build option from the toolbar menu:
1348 | Chapter 24 Creating Macros with Revit VSTA
Содержание 24000-000000-9860 - Revit Architecture - PC
Страница 1: ...Revit Architecture 2009 User s Guide April 2008 240A1 050000 PM02A ...
Страница 4: ......
Страница 56: ...18 ...
Страница 116: ...78 Chapter 3 Revit Essentials ...
Страница 172: ...134 Chapter 4 ProjectViews ...
Страница 178: ...Schedule with Grid Lines Schedule with Grid Lines and an Outline 140 Chapter 4 ProjectViews ...
Страница 352: ...Defining the first scale vector Defining the second scale vector 314 Chapter 7 Editing Elements ...
Страница 554: ...516 ...
Страница 739: ...Curtain wall Curtain Grid Curtain Walls Curtain Grids and Mullions 701 ...
Страница 898: ...Pile caps with multiple piles Rectangular and triangular pile caps 860 Chapter 12 Working with Structural Components ...
Страница 1004: ...966 ...
Страница 1136: ...1098 ...
Страница 1226: ...1188 ...
Страница 1250: ...1212 ...
Страница 1276: ...1238 Chapter 20 Design Options ...
Страница 1310: ...1272 ...
Страница 1366: ...1328 ...
Страница 1406: ...1368 ...