Opens and activates a Revit document, include both local document or cloud document.
Namespace: Autodesk.Revit.UIAssembly: RevitAPIUI (in RevitAPIUI.dll) Version: 21.0.0.0 (21.1.1.109)
Since: 2012
Syntax
C# |
---|
public UIDocument OpenAndActivateDocument( string fileName ) |
Visual Basic |
---|
Public Function OpenAndActivateDocument ( _ fileName As String _ ) As UIDocument |
Visual C++ |
---|
public: UIDocument^ OpenAndActivateDocument( String^ fileName ) |
Parameters
- fileName
- Type: System..::..String
A full path to a revit file to be opened. The file can be either a Revit project, template, or family document.
Return Value
The opened document.
Remarks
This method, if successful, changes the active document.
It is not allowed to have an open transaction in the active document when calling this method.
Additionally, this method may not be called from inside an event handler.
Exceptions
Exception | Condition |
---|---|
Autodesk.Revit.Exceptions..::..ArgumentException | The given 'fileName' is not a Revit file (a project, template, or family document). |
Autodesk.Revit.Exceptions..::..ArgumentNullException | If nullNothingnullptra null reference (Nothing in Visual Basic) is passed as 'fileName'. -or- A non-optional argument was NULL |
Autodesk.Revit.Exceptions..::..FileArgumentNotFoundException | The file specified by 'fileName' cannot be found. |
Autodesk.Revit.Exceptions..::..InvalidOperationException |
|
Autodesk.Revit.Exceptions..::..RevitServerCommunicationException | If there is any server internal error. |