Hello everybody, I spent >20 hr trying to solve my issue, digging through forum and I have a feeilng I hit a wall I can’t get through.
Idea for scripct was simple: pefrom batch link of multiple DWGs to appropriate FloorPlanViews. All data would be stored in CSV file, example:
File Path,View
C:\filepath\Link1.dwg,FloorPlan Level 1 - Overall
C:\filepath\Link2.dwg,FloorPlan Level 2 - Overall
C:\filepath\Link3.dwg,FloorPlan Level 3 - Overall
In my theory python script should be fed by 2 lists of STRING created out of CSV file (list with file paths, list with assigned names of floor plan views).
I found some python script which I was trying to edit (I am not familiar with Python). I managed to force script for loading multiple files by using while loop but since that script wants to be fed by single FloorPlanView element I don’t know how to force it to convert read strings from list of FloorPlanViews names into FloorPlanViews and insert DWGs into appropriate levels.
Script below:
import clr clr.AddReference('ProtoGeometry') from Autodesk.DesignScript.Geometry import *clr.AddReference(“RevitServices”)
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManagerdoc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Applicationclr.AddReference(“RevitAPI”)
import Autodesk
from Autodesk.Revit.DB import *dataEnteringNode = IN
filePath = IN[0]
view = UnwrapElement(IN[1])
i = 0for item in IN[0]:
t = IN[0].index(item)
t = t+1filePath_ = filePath[i]
view_ = view[i]options = DWGImportOptions()
options.AutoCorrectAlmostVHLines = False
options.ColorMode = ImportColorMode.Preserved
options.OrientToView = True
options.ThisViewOnly = False
options.VisibleLayersOnly = Truewhile i<t:
linkedElem = clr.ReferenceElementId
TransactionManager.Instance.EnsureInTransaction(doc)
doc.Link(filePath_, options, view_, linkedElem)
TransactionManager.Instance.TransactionTaskDone()
i=i+1
if i<t:
filePath_ = filePath[i]
view_ = view[i]OUT = i
Any ideas?