Application Functions

Application Functions

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.

Application

The class represents the Autodesk Revit Application, providing access to documents, options and other application wide data and settings.

Application Version Information

Application properties include VersionBuild, VersionNumber and VersionName. These can be used to provide add-in behavior based on the release and build of Revit, as shown in How to use Application properties to enforce a correct version for your add-in.

Application-wide Settings

The SharedParametersFilename property and GetLibraryPaths() and SetLibraryPaths() methods provide access to these application-wide settings.

Document Management

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.

Session Information

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.

Events

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.

Create

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.

UIApplication

This class represents an active session of the Autodesk Revit user interface, providing access to UI customization methods, events, and the active document.

Document Management

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.

Add-in Management

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.

Ribbon Panel Utility

Use the UIApplication object to add new ribbon panels and controls to Revit.

For more details, see Ribbon Panel and Controls in the Add-In Integration section.

Extents

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

Events

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.