Created
November 20, 2018 14:08
-
-
Save johnpierson/7cf16606b8e61cf26786c20e662122e6 to your computer and use it in GitHub Desktop.
Example for background open of revit docs.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Autodesk.DesignScript.Runtime; | |
using System.Collections.Generic; | |
using Autodesk.Revit.DB; | |
using RevitServices.Persistence; | |
namespace ZeroTouchNode.Revit.Application | |
{ | |
/// <summary> | |
/// Wrapper class for application level nodes. | |
/// </summary> | |
public class Applications | |
{ | |
private Applications() | |
{ } | |
/// <summary> | |
/// This node will open the given file in the background. | |
/// </summary> | |
/// <param name="filePath">The file to obtain document from.</param> | |
/// <param name="audit">Choose whether or not to audit the file upon opening. (Will run slower with this)</param> | |
/// <param name="detachFromCentral">Choose whether or not to detach from central upon opening. Only for RVT files. </param> | |
/// <returns name="document">The document.</returns> | |
/// <search> | |
/// Application.OpenDocumentFile, rhythm | |
/// </search> | |
public static Autodesk.Revit.DB.Document OpenDocumentFile(string filePath, bool audit = false, bool detachFromCentral = false) | |
{ | |
var uiapp = DocumentManager.Instance.CurrentUIApplication; | |
var app = uiapp.Application; | |
//declare open options for user to pick to audit or not | |
OpenOptions openOpts = new OpenOptions(); | |
openOpts.Audit = audit; | |
if (detachFromCentral == false) | |
{ | |
openOpts.DetachFromCentralOption = DetachFromCentralOption.DoNotDetach; | |
} | |
else | |
{ | |
openOpts.DetachFromCentralOption = DetachFromCentralOption.DetachAndPreserveWorksets; | |
} | |
//convert string to model path for open | |
ModelPath modelPath = ModelPathUtils.ConvertUserVisiblePathToModelPath(filePath); | |
return app.OpenDocumentFile(modelPath, openOpts); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@sabeelcoder this code was made to be implemented on ZeroTouch Node. The link below is one reference of how to do this.
https://developer.dynamobim.org/03-Development-Options/3-0-developing-for-dynamo.html