openDocumentFile

Hi @Yien I hope you’re well.

Try this:

import clr

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager

clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *

doc = DocumentManager.Instance.CurrentDBDocument
app = doc.Application

filePath = IN[0]
modelPath = ModelPathUtils.ConvertUserVisiblePathToModelPath(filePath)

options = OpenOptions()
options.DetachFromCentralOption = DetachFromCentralOption.DetachAndPreserveWorksets

docOnDisk = app.OpenDocumentFile(modelPath, options)

OUT = docOnDisk

There were a few updates required:

  1. You need to instantiate your options object first, then set its DetachFromCentralOption property.
  2. Its DetachFromCentralOption requires a DetachFromCentralOption enum and you need to assign it to the property (so you need to use the = statement)
  3. To obtain the Application object use the active document Application property
  4. Call OpenDocumentFile from your Application object as its not a static method
4 Likes