Opens and activates a Revit document, include both local document or cloud document.
Namespace: Autodesk.Revit.UI
Assembly: RevitAPIUI (in RevitAPIUI.dll) Version: 25.3.0.0 (25.3.0.0)
Syntax
C#
public UIDocument OpenAndActivateDocument( ModelPath modelPath, OpenOptions openOptions, bool detachAndPrompt )
Parameters
- modelPath ModelPath
- A path to a Revit file to be opened. The file can be either a Revit project, template, or family document.
- openOptions OpenOptions
- Options for opening the file.
- detachAndPrompt Boolean
- True means if openOptions specifies DoNotDetach, then for workshared models detach from central and query the user whether to preserve or discard worksets. make no sense when opening a cloud document.
Return Value
UIDocumentThe opened document.
Exceptions
Exception | Condition |
---|---|
ArgumentException |
If DetachFromCentralOption is not DoNotDetach when opening a cloud document.
|
ArgumentNullException | If null is passed as 'modelPath'. -or- If null is passed as 'openOptions'. -or- A non-optional argument was null |
CannotOpenBothCentralAndLocalException | Cannot open the local model and the central model in the same Revit session. You can close one to open the other in the same Revit session. |
CentralModelAccessDeniedException | Thrown when file is not found at the give path. |
CentralModelException |
|
CorruptModelException | There are too many corrupt elements to open this model. |
FileAccessException |
|
FileArgumentNotFoundException | The file specified by 'modelPath' cannot be found or the given 'modelPath' is not a Revit file (a project, template, or family document). |
InsufficientResourcesException | This computer does not have enough memory, disk space, or other necessary resource to open the model. |
InvalidOperationException |
The cloud model is not saved in current release of Revit.
-or-
The model is not allowed to access.
-or-
|
OperationCanceledException | Opening was canceled by the user or by an API event callback. |
RevitServerCommunicationException | If there is any server internal error. |
RevitServerUnauthenticatedUserException | User is not signed in with Autodesk id when trying to open a cloud model. |
RevitServerUnauthorizedException | User is not authorized to access the cloud model. |
ServerModelCorruptedException | The central model is corrupted. This exception is treated starting from Revit 2025.2. |
WrongUserException | The local file is not owned by the current user, who therefore is not allowed to modify it. |