Application functions provide access to documents, objects, and other application data and settings. All Application and UIApplication functions are identified and defined in the following sections.
The class represents the Autodesk Revit Application, providing access to documents, options and other application wide data and settings.
The SharedParametersFilename property and GetLibraryPaths() and SetLibraryPaths() methods provide access to these application-wide settings.
The Application class provides methods to create the following types of documents:
- Family document
- Project document
- Project template
The OpenDocumentFile() method can be used to open any of these document types.
All open documents can be retrieved using the Documents property.
For more details, see Document and Management.
Properties such as UserName and methods such as GetRevitServerNetworkHosts() provide read-only access to this session specific information.
Shared Parameter Management
Revit uses one shared parameter file at a time. The Application.OpenSharedParameterFile() method accesses the shared parameter file whose path is set in the SharedParametersFilename property. For more details, see Shared Parameter.
The Application class exposes document and application events such as document open and save. Subscribing to these events notifies the application when the events are enabled and acts accordingly. For more details, see Access to Revit Event in the Add-In Integration section.
The Create property returns an Object Factory used to create application-wide utility and geometric objects in the Revit Platform API. Create is used when you want to create an object in the Revit application memory rather than your application's memory.
Failure Posting and Handling
The FailureDefinitionRegistry, which contains all registered FailureDefinitions is available from the static GetFailureDefinitionRegistry() method. The static method RegisterFailuresProcessor() can be used to register a custom IFailuresProcessor. For more information on posting and handling failures, see Failure Posting and Handling.
This class represents an active session of the Autodesk Revit user interface, providing access to UI customization methods, events, and the active document.
The UIApplication provides access to the active document using the UIActiveDocument property. Additionally, a Revit document may be opened using the overloaded OpenAndActivateDocument() method. The document will be opened with the default view active. This method may not be called inside a transaction and may only be invoked during an event when no active document is open yet in Revit and the event is not nested inside another event.
The ActiveAddInId property gets the current active external application or external command id, while the LoadedApplications property returns an array of successfully loaded external applications.
The DrawingAreaExtents property returns a rectangle that represents the screen pixel coordinates of drawing area, while the MainWindowExtents property returns the rectangle that represents the screen pixel coordinates of the Revit main window
The UIApplication class exposes UI related events such as when a dialog box is displayed. Subscribing to these events notifies the application when the events are enabled and acts accordingly. For more details, see Access to Revit Event in the Add-In Integration section.