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:
- Open a series of files in a directory
- Detach
- Run a series of scripts
- 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.
Script:
Enable Python support and load DesignScript library
import clr
clr.AddReference(‘ProtoGeometry’)
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
clr.AddReference(‘ProtoGeometry’)
from Autodesk.DesignScript.Geometry import *
Import DocumentManager and TransactionManager
clr.AddReference(“RevitServices”)
import RevitServices
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
Import RevitAPI
clr.AddReference(“RevitAPI”)
import Autodesk
from Autodesk.Revit.DB import *
if isinstance(IN[0], list):
files = IN[0]
else:
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()
SaveOptions.SetWorksharingOptions(worksharingOptions)
tOptions = TransactWithCentralOptions()
rOptions = RelinquishOptions(False)
for file in files:
modelpath = FilePath(file)
newdoc = app.OpenDocumentFile(modelpath,options)
newfile = file[:-42] + jobnumber + " " + projectname + " " + v + “.rvt”
newdoc.SaveAs(newfile,SaveOptions)
rOptions.StandardWorksets = True
rOptions.ViewWorksets = True
rOptions.FamilyWorksets = True
rOptions.UserWorksets = True
rOptions.CheckedOutElements = True
sOptions = SynchronizeWithCentralOptions()
sOptions.SetRelinquishOptions(rOptions)
sOptions.Compact = True
newdoc.SynchronizeWithCentral(tOptions, sOptions)
newdoc.Close(False)
OUT = 0