I am trying to convert Rhythm’s Open Document zero touch node to Python so that I can add an option to discard worksets. I am getting an EOF error at the moment, I am probably missing something obvious. We won’t have to worry about adding a for loop or anything since I am putting it into a .dyf
# Enable Python support and load DesignScript library
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import *
from RevitServices.Transactions import TransactionManager
# The inputs to this node will be stored as a list in the IN variables.
filePath = IN[0]
audit = IN[1]
detachFromCentral = IN[2]
preserveWorksets = IN[3]
# Place your code below this line
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
#instantiate open options for user to pick to audit or not
openOpts = OpenOptions()
openOpts.Audit = audit
#tOpt = TransmittedModelOptions.SaveAsNewCentral
if detachFromCentral == False:
openOpts.DetachFromCentralOption = DetachFromCentralOption.DoNotDetach
else:
if preserveWorksets:
openOpts.DetachFromCentralOption = DetachFromCentralOption.DetachAndPreserveWorksets
else:
openOpts.DetachFromCentralOption = DetachFromCentralOption.DetachAndDiscardWorksets
#convert string to model path for open
modelPath = ModelPathUtils.ConvertUserVisiblePathToModelPath(filePath)
try:
docTitle = DocumentUtils.OpenDocument(modelPath, openOpts)
OUT = docTitle
#don't remember how to handle these, it throws it everytime so is off at the moment
#except:
# OUT = 'error'
Here’s the the “File Management” dyf it is going to end up in btw.
I’m just testing it against a single workshared file that is linked to a central model at the moment. It will typically extract the files out a directory and push those into the dyf.
Although not a direct answer, perhaps this set of python code could get you to be able to read out the error report at least, or see how the files are being read in.
EOF means “end of file”. It is being raised when you’re code cannot be read to the end. Always look for syntax mistakes, such as missing brackets, if you get it.
In this case your try statement is missing an exception. You can either comment out the try and indent the rest accordingly, or add except: pass to ignore all exceptions.
Does anyone know where the DocumentUtils class is coming from? As noted in the post Sean has linked to, documents are usually opened using the current Application.