Example: Document-Level Macro in VB.NET
For the next example, in Macro Manager, select DocVisualBasic and click New.
Give your macro a name, such as
MyFirstMacroDocVB
.
In the IDE, use the following code for the method:
Public Sub MyFirstMacroDocVB()
Dim baseVec As Autodesk.Revit.Geometry.XYZ = Me.Application.Create.NewXYZ(1.0, 0.0, 0.0)
Dim upVec As Autodesk.Revit.Geometry.XYZ = Me.Application.Create.NewXYZ(0.0, 0.0, 1.0)
Dim origin As Autodesk.Revit.Geometry.XYZ = Me.Application.Create.NewXYZ(0.0, 0.0, 0.0)
Dim align As Autodesk.Revit.Enums.TextAlignFlags =
Autodesk.Revit.Enums.TextAlignFlags.TEF_ALIGN_LEFT Or
Autodesk.Revit.Enums.TextAlignFlags.TEF_ALIGN_TOP
Dim strText As String = "My First Macro, Doc Level, VB.NET!"
Dim lineWidth As Double = 4.0 / 12.0
Dim pView As Autodesk.Revit.Elements.View = Me.ActiveView
Me.Create.NewTextNote(pView, origin, baseVec, upVec, lineWidth, align, strText)
End Sub
TIP
Be sure to build your project in the Revit VSTA IDE before trying to run it from Macro Manager.
For this example, when you build the project in the Revit VSTA IDE, notice that you are building the
DocVisualBasic project, and your Document-level VB.NET macro's code resides in ThisDocument.vb. You
can use the IDE's Project Explorer to see its temporary location on disk. Recall that the code for successfully
built Document-level macros are stored in the .rvt file after you Save the .rvt file; the project files are removed
from the temporary location when you exit Revit.
To run your newly built macro, select it in Macro Manager and click Run. Then if necessary, right-click in
the active view and select Zoom to Fit from the menu to see the Text Note added by your macro.
Using the StepInto Option
You can debug your macros by using StepInto option in Macro Manager and features in the Revit VSTA IDE:
■
Open the code for your macro in the IDE.
■
To set breakpoints, click in the left margin of the code window, or click in the code and press F9 or Toggle
Breakpoint in the Debug menu.
■
Then switch to Macro Manager. Select your macro from the categorized list, and click StepInto. The
macro will stop at the first line.
■
Press F5 or Continue to move to the breakpoint.
1352 | 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 ...