Revit API 2012 provides one more application type, IExternalDBApplication, which is supposed to help do some DB stuffs at Revit startup, monitor some document events, and so on. In this post, we are going to see how to revoke Document Close related operations using events in an External DB Application (IExternalDBApplication).
It is obvious that the DocumentClosing document event needs to be lisented to in the OnStartup point as follows:
_cachedCtrlApp.DocumentClosing += new EventHandler<DocumentClosingEventArgs>(_cachedCtrlApp_DocumentClosing);
Then we can implement the event handlers like:
void _cachedCtrlApp_DocumentClosing(object sender, DocumentClosingEventArgs e)
{
if (e.Cancellable)
{
MessageBox.Show("Document cannot be closed!");
e.Cancel();
}
}
Then whenever a document is going to be closed a message will show up and the document closing operation will be revoked. I know it is not so much fun, but it can tell us what can be done by the Revit events and the IExternalDBApplication of Revit API.
In terms of some full implementation example code of such an IExternalDBApplication, please check on earlier posts.
Revit Addin Wizard (RevitAddinWizard) is going to provide an External DB Application wizard to help implement the IExternalDBApplication interface automatically and reliably. With the assistance of the External DB Application wizard and some event wizards, all the code can be created conveniently in a minute.
Recent Comments