Link multiple DWG files, DWGImportOptions

I am trying to link multiple DWG files into Revit using the Link Method. I get the error:

TypeError: expected DGNImportOptions, got DWGImportOptions
As I understand it from the Revit API docs, the Link Method can take both of these import options.
How do i make it expect DWGImportOptions?

Here is my code:

doc = DocumentManager.Instance.CurrentDBDocument
TransactionManager.Instance.EnsureInTransaction(doc)

filepaths = IN[0]
view = IN[1]

DWGoptions = DWGImportOptions()
DWGoptions.Placement = ImportPlacement.Origin
DWGoptions.OrientToView = True

for filepath in filepaths:
	loadResult = doc.Link(filepath, DWGoptions, view)
       

TransactionManager.Instance.TransactionTaskDone()

This is how it looks in Dynamo

And here is the RevitAPI link:
https://www.revitapidocs.com/2020/0e45b625-904e-06be-fabc-8591fed616f8.htm

Hi @magpies,

You didn’t unwrap the view.
view = UnwrapElement(IN[1])

You can also use the Genius Loci or Morpheus packages for this task.

1 Like

Thank you! I’ll check out those packages as well

Hi!
I’m trying to use the node “LinkDwg.AtOrigin” of Morpheus package for a link multiple DWG in diferent views. I’m a beginner user of dynamo.

I’ve prepared an excel with all views on first column and all file paths in the second one.
So, I’ve imported data to dynamo, I’ve create two lists, file paths and vides, but when I run the rutine I get an error, and I don’t know why.

If I punt only one file path anda one view, rutine works perfectly. But I need to link several DWG…

Could you help me?
Thanks