Automate Opening files, detach, run a series of scripts then re-save in a new location

Hi there,

relative newb to dynamo, and have been trying to automate a task for the past year, made lots of progress but now stuck. We have a specific process of file exchange with consultants ( Pre-historic to BIM 360 sharing and export/publish dosen’t quite do what is needed) I am trying to:

  1. Open a series of files in a directory
  2. Detach
  3. Run a series of scripts
  4. Re-save in a new location with the same file name

I’ve borrowed a python script from online which seems to be close to making step 1.2 and 3 happen.As I don’t know phython I am trying to let 1.2.3 open and close then try and run 3 seperatly. I am just struggling to connect it together with my scripts. any help appreciated.


Enable Python support and load DesignScript library

import clr
from Autodesk.DesignScript.Geometry import *

The inputs to this node will be stored as a list in the IN variables.

dataEnteringNode = IN

Place your code below this line

import clr
from Autodesk.DesignScript.Geometry import *

Import DocumentManager and TransactionManager

import RevitServices
from RevitServices.Persistence import DocumentManager

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

Import RevitAPI

import Autodesk
from Autodesk.Revit.DB import *

if isinstance(IN[0], list):
files = IN[0]
files = [IN[0]]

v = “R” + app.VersionNumber[2:]
jobnumber = IN[1]
projectname = IN[2]
newpath = IN[3]
options = OpenOptions()
options.DetachFromCentralOption = DetachFromCentralOption.DetachAndPreserveWorksets

worksharingOptions = WorksharingSaveAsOptions()
worksharingOptions.SaveAsCentral = True

SaveOptions = SaveAsOptions()
tOptions = TransactWithCentralOptions()
rOptions = RelinquishOptions(False)

for file in files:
modelpath = FilePath(file)
newdoc = app.OpenDocumentFile(modelpath,options)
newfile = file[:-42] + jobnumber + " " + projectname + " " + v + “.rvt”
rOptions.StandardWorksets = True
rOptions.ViewWorksets = True
rOptions.FamilyWorksets = True
rOptions.UserWorksets = True
rOptions.CheckedOutElements = True
sOptions = SynchronizeWithCentralOptions()
sOptions.Compact = True
newdoc.SynchronizeWithCentral(tOptions, sOptions)

OUT = 0

Pink sections are the scripts that need to run on the file and I know work

There’s a playlist feature in Orkestra that will allow you to run several definition one after the other


Thanks Daniel, I’m looking at the software clarity at the moment that could maybe also do the same thing. Just trying to see if the playlist feature in Orkestra will open a file automatically and then re-save.It looks like it does

1 Like

what is it? can you edit a revit file opened in the background? I can read it but not edit as far I know. Clarity Server of Sofitik does that job to execute scripts from the website and server without even open the softwares but I just want to use Dynamo.

You can do whatever Dynamo can do and also run several scripts in a row

1 Like

Holy sh*t, Orkestra looks awesome!

1 Like