I make this work but it handles one single item as input, I need a list.
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
You need to provide a looping mechanism for each action which requires a list. In this context utilizing List Comprehension may be easiest to implement.
The structure is basically this:
‘variable
= [
thingToDo
for``item
in
list
]
You can find lots of good tutorials on this online.
Your first action which needs to loop might look like this (on my phone and my python app wont start so pardon any inaccuracies):
modelPaths = [ ModelPathUtils.ConvertUserVisiblePathToModelPath(path) for path in filePaths ]
I am working on this now too and found this post- so this will not iterate and I dont know why?
yeah I just made a post out of it working with documents is such a hassle lol. this is really just me learning one step of this as I need a way to get elements from an external document to copy.
2 Likes