Thanks, had to wait til the next project to fix it but this works great : )
Im trying to get people to stop using autocad for 2D details so being able to import all their standard dwgs in one click should help.
Modified it slightly to handle a list of views/paths and to output a list of the views created;
"# Link DWGs
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.CustomScale = 100
#options.Placement = Origin
LinkedElem = clr.Reference[ElementId]()
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;
";
Is there a good way to make code 'list or single item proof"? I prefer to use code in a string where it can be edited directly rather than putting it in a custom node every time.