We talked about Revit Application and ControlledApplication before. In this article, let us have a look at the Revit UIApplication and UIControlledApplication.
Both UIApplication and UIControlledApplication classes are in the Revit API Autodesk.Revit.UI namespace. They are both derived from the System.Object .NET type and do not have any inheritance relationship between each other though they share most of methods, properties, and events.
Let’s look at their methods first. The UIApplication type even provides a constructor and we can create a Revit UIApplication object if we like. But please be carefully. As we talked in another article:
Revit API: Application and UIApplication
The constructor of UIApplication type is picky. It accepts the real Application object which can be retrieved from the ExternalCommandData.Application.Application but does not accept one created from an Application type explicitly like new Autodesk.Revit.ApplicationServices.Application().
It also has a Dispose() method but it does not seem to do anything.
Except for the constructor and the Dispose method, UIApplication shares all the other methods, most of which are inherited from the Object type, with UIControlledApplication:
CreateRibbonPanel
Equals
GetHashCode
GetRibbonPanels
GetType
ToString
In terms of properties, the UIControlledApplication type has only three properties:
ControlledApplication
ActiveAddInId
LoadedApplications
The ControlledApplication property is unique to the UIControlledApplication type and the other two are shared with UIApplication. Besides the two, the UIApplication has some extra properties:
Application
ActiveUIDocument
DrawingAreaExtents
MainWindowExtents
The Application property in the UIApplication type is the counterpart of the ControlledApplication property in the UIControlledApplication clearly.
Now events: both UIApplication and UIControlledApplication classes have the following events and they have no reasons to carry anything different or behave different, even a bit:
ApplicationClosing
DialogBoxShowing
Idling
ViewActivated
ViewActivating
It is understandable that two types of the same UI application are provided to address different entry points, external application startup and external command execution, but it would make more sense that one is derived from another since they share most of stuffs and they behave just exactly the same or event better to merge them into a single one to avoid confusions.
What about LightUIApplication and FullUIApplication and the latter inherits everything from the former and adds its own methods, properties and events? Or simpler providing a single UI application type and just throws out exceptions in those non-applicable properties and methods in the controlled UI application to warn people? Or the simplest just getting these documented?
RevitAddinWizard cannot do much about these but it can help create a lot of code automatically in no time, such as External Application creation and entry point setup, External Command creation and entry point set up, UIApplication/UIControlledApplication even handlers and hook up, Application/ControlledApplication event handlers and hookup, Document event handlers and hookup, and so on.
Our Software http://netspiderstudio.com/Software.html
Support: mailto:[email protected]
Query: mailto:[email protected]
Blog: http://spiderinnet.typepad.com
More: http://netspiderstudio.com
Recent Comments