Insert CADLinks in views

revit
dynamo
python

#1

Hi! I’m new to Dynamo and python. Now I’m tring to insert cadlinks in conrresponding views. I found this attached python script which work perfect with one cad to one view, but when I change it to do with multiple files this error appear “EOL while scanning single-quoted string”

import clr
clr.AddReference(‘ProtoGeometry’)
from Autodesk.DesignScript.Geometry import *

Import DocumentManager and TransactionManager

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

Import RevitAPI

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

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

filePaths = IN[0]
views = UnwrapElement(IN[1])
viewsplaced=list()

options = DWGImportOptions()
options.AutoCorrectAlmostVHLines = True
options.ColorMode = ImportColorMode.BlackAndWhite
options.OrientToView = True
options.ThisViewOnly = True
options.VisibleLayersOnly = True
options.Unit = ImportUnit.Meter
options.Placement= ImportPlacement.Centered

linkedElem = clr.ReferenceElementId

for view in range(len(views)):
TransactionManager.Instance.EnsureInTransaction(doc)
doc.Link(filePaths[view], options, views[view], linkedElem)
TransactionManager.Instance.TransactionTaskDone()
viewsplaced.append(views[view])

#Assign your output to the OUT variable.
OUT = viewsplaced;
";


#2

Hi @L_VADU,

Welcome to the forum.

It looks like you have an error with the filepaths but it’s hard to know without seing a screenshot.
If you don’t want to use a python script, there are custom nodes to link or import DWGs.


#3

Thank you so much!!!