Get Views (List of FloorPlanViews) by Name (List of string)

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. :frowning:

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 TransactionManager

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

clr.AddReference(“RevitAPI”)
import Autodesk
from Autodesk.Revit.DB import *

dataEnteringNode = IN

filePath = IN[0]
view = UnwrapElement(IN[1])
i = 0

for item in IN[0]:
t = IN[0].index(item)
t = t+1

filePath_ = filePath[i]
view_ = view[i]

options = DWGImportOptions()
options.AutoCorrectAlmostVHLines = False
options.ColorMode = ImportColorMode.Preserved
options.OrientToView = True
options.ThisViewOnly = False
options.VisibleLayersOnly = True

while 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?

Hi @wrobel.joachim,

Vou must connect views and not strings to the python script…
You can retrieve views by their names.

Some of this nodes could help you :

Thanks for quick response, I was hoping that maybe I can call existing views somehow inside python script using given strings without extra nodes, but I will try what you suggested anyway. :slight_smile: