Question
Private Sub Module_Startup(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Startup
AddHandler Me.OnDocumentNewed, AddressOf Me.ThisApplication_On
DocumentNewed
End Sub
Private Sub Module_Shutdown(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Shutdown
RemoveHandler Me.OnDocumentNewed, AddressOf Me.ThisApplica
tion_OnDocumentNewed
End Sub
Private Sub ThisApplication_OnDocumentNewed(ByVal document As
Autodesk.Revit.Document)
System.Windows.Forms.MessageBox.Show("VB.NET Application event
OnDocumentNewed")
End Sub
C# Example, Application-level:
private void Module_Startup(object sender, EventArgs e)
{
this.OnDocumentNewed += new Autodesk.Revit.Events.Document
NewedEventHandler(ThisApplication_OnDocumentNewed);
}
private void Module_Shutdown(object sender, EventArgs e)
{
this.OnDocumentNewed -= new Autodesk.Revit.Events.Document
NewedEventHandler(ThisApplication_OnDocumentNewed);
}
void ThisApplication_OnDocumentNewed(Document document)
{
System.Windows.Forms.MessageBox.Show("C# Application event
OnDocumentNewed");
}
Related Information about Revit Macros
Quick Reference
To learn more, please refer to the following resources:
The Revit*API.chm Help file contains the Revit API .NET reference documentation. The API reference
documentation is provided with the Revit SDK, which is on the product DVD and the Autodesk web site:
http://www.autodesk.com/revit-sdk. Be sure to access the Revit API SDK for your release of Revit. As noted
earlier in this topic, the SDK also includes the Revit VSTA samples.
DevTV: Introduction to Revit Programming, is a video on autodesk.com that you can download. The
narrated video covers the Revit API for external commands and external applications. It does not describe
the macros functionality with Revit VSTA, but should be of interest to developers who are looking for
more details about the full Revit SDK API and its samples. See http://www.autodesk.com/revit-sdk, and look
for the section that starts with "DevTV."
1448 | Chapter 26 Creating Macros with Revit VSTA
Answer
Need help?
Do you have a question about the 256B1-05A761-1301 - AutoCAD Revit Structure Suite 2010 and is the answer not in the manual?
Questions and answers