
Answer
Question
use
this.Application
or
Me.Applic-
ation.
The
Module_Startup
method is called
a module loads and
Module_Shutdown
What should I include in the startup and
shutdown methods:
Module_Startup
,
Module_Shutdown
,
Module_Startup
,
and
Module_Shutdown
?
is called when a module unloads.
Module
Startup
will be called only when the
corresponding tab is selected or when the
macro project is rebuilt.
Module_Startup
is called when a Revit
project opens and
Module_Shutdown
is
called when the project document closes.
You can add your initializing code in the
Module_Startup
methods and do the
cleanup work in
Module_Shutdown
methods. For example, you can register
event handlers at start up and unregister
them at shutdown (which is the recommen-
ded way).
As noted previously, the recommended
way to do this in Revit VSTA is to register
How and why should I register and unre-
gister my Revit event handler?
event handlers in the
*_Startup
method
and unregister them in the
*_Shutdown
method. Every VSTA macro will be loaded
and unloaded dynamically. When you de-
bug a macro, if the event handler is not
properly unregistered, Revit may call a
wrong method (maybe an invalid memory
address). Although Revit VSTA may prevent
Revit from crashing in this scenario, any
event handlers that are not properly unre-
gistered may cause performance issues
during your current Revit session.
Modeless dialogs operating outside the
scope of a running API callback may cause
I have a dialog that does not seem to work
correctly and is causing issues with Revit.
problems. It is recommended that you
avoid such callbacks to prevent instability
in Revit.
The following sample code shows how to
register an
OnDocumentNewed
event
I want to experiment with the Startup and
Shutdown methods and an event handler.
Can you show me an example?
handler, which will automatically launch a
message box when a new Revit project is
created. Note: One of the VSTA samples
provided on the Revit SDK may show an
example of a document-level event hand-
ler's startup and shutdown. This FAQ shows
Application-level event handler examples.
Please note that 2010 events are not in-
cluded with Revit VSTA IDE 2010.
VB.NET example, Application-level:
Revit Macros FAQ | 1447
Summary of Contents for 256B1-05A761-1301 - AutoCAD Revit Structure Suite 2010
Page 1: ...Revit Architecture 2010 User s Guide March 2009 ...
Page 4: ......
Page 42: ...xlii ...
Page 84: ...42 ...
Page 126: ...84 ...
Page 166: ...124 ...
Page 229: ...Schedule Field Formatting Calculating Totals Specifying Schedule Properties 187 ...
Page 230: ...Schedule with Grid Lines Schedule with Grid Lines and an Outline 188 Chapter 5 Project Views ...
Page 304: ...262 ...
Page 427: ...Defining the first scale vector Defining the second scale vector Resizing Graphically 385 ...
Page 454: ...Before painting applying material to stairs 412 Chapter 8 Editing Elements ...
Page 456: ...414 ...
Page 486: ...444 ...
Page 674: ...632 ...
Page 809: ...Curtain wall Curtain Grid Curtain Walls Curtain Grids and Mullions 767 ...
Page 994: ...952 ...
Page 1016: ...974 ...
Page 1204: ...1162 ...
Page 1290: ...1248 ...
Page 1318: ...1276 ...
Page 1372: ...1330 ...
Page 1382: ...1340 ...
Page 1462: ...1420 ...
Page 1492: ...1450 ...