Autodesk 24000-000000-9860 - Revit Architecture - PC User Manual page 1388

User guide
Table of Contents

Advertisement

Then look for the Text Note and zoom-in on it, to verify that the macro worked. In the case of the view we
used, the Text Note appeared far to the right of the model. Your location may be different. When we zoomed
in and selected the Text Note, it looked like this:
Although you can experiment with the XYZ coordinates in the macro code (including negative numbers
like -300 for the X origin), the real point of this example is to notice that the macro really did add the text
note.
To remove the Text Note, you can select and delete it, or choose Edit
Revit toolbar menu.
Example:Application-level Macro in VB.NET
Next let's return to the Macro Manager and add a similar example, this time in VB.NET.
In Macro Manager, select AppVisualBasic, and click New.
Give your macro a name, such as
In the IDE, use the following code for the method:
Public Sub MyFirstMacroAppVB()
Dim baseVec As Autodesk.Revit.Geometry.XYZ = Me.Create.NewXYZ(1.0, 0.0, 0.0)
Dim upVec As Autodesk.Revit.Geometry.XYZ = Me.Create.NewXYZ(0.0, 0.0, 1.0)
Dim origin As Autodesk.Revit.Geometry.XYZ = Me.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, App Level, VB.NET!"
Dim lineWidth As Double = 4.0 / 12.0
Dim pView As Autodesk.Revit.Elements.View = Me.ActiveDocument.ActiveView
Me.ActiveDocument.Create.NewTextNote(pView, origin, baseVec, upVec, lineWidth, align,
strText)
End Sub
In this VB.NET example, we used the
used a different
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
AppVisualBasic
use the IDE's Project Explorer to see its location on disk. To run your newly built macro, select it in Macro
1350 | Chapter 24 Creating Macros with Revit VSTA
MyFirstMacroAppVB
Me
value for the Text Note.
strText
project. Your Application-level VB.NET macro's code resides in ThisApplication.vb. You can
.
keyword pointer (instead of the
Undo Macro (Ctrl+Z) from the
keyword pointer). Also we
this

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the 24000-000000-9860 - Revit Architecture - PC and is the answer not in the manual?

Questions and answers

Table of Contents

Save PDF