Application and Document. Autodesk 2014 Platform API
Reklama
Reklama
Application and Document
The top level objects in the Revit Platform API are application and document. These are represented by the classes Application,
UIApplication, Document and UIDocument.
•
The application object refers to an individual Revit session, providing access to documents, options, and other application-wide data and settings. o
Autodesk.Revit.UI.UIApplication - provides access to UI-level interfaces for the application, including the ability to add
RibbonPanels to the user interface, and the ability to obtain the active document in the user interface. o
Autodesk.Revit.ApplicationServices.Application - provides access to all other application level properties.
•
The document object is a single Revit project file representing a building model. Revit can have multiple projects open and multiple views for one project. o
Autodesk.Revit.UI.UIDocument - provides access to UI-level interfaces for the document, such as the contents of the selection and the ability to prompt the user to make selections and pick points o
Autodesk.Revit.DB.Document - provides access to all other document level properties
•
If multiple documents are open, the active document is the one whose view is active in the Revit session.
This chapter identifies all Application and Document functions, and then focuses on file management, settings, and units. For more details about the Element class, refer to Elements Essential s and Editing Elements and refer to the Views for more details about the view elements.
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.
Stiahnuť
Reklama