This post is about how you can copy levels and grids from the linked document to the current document by using IronPython in Revit Dynamo Application.
First to import the modules; clr to load .Net Assemblies as IronPython modules which are RevitAPI.dll for DB, RevitServices.dll for DocumentManager and TransactionManager and System for .Net List. Collect the current document and store in doc variable.
import clr,System clr.AddReference("RevitServices") clr.AddReference("RevitAPI") from Autodesk.Revit.DB import * from System.Collections.Generic import List from RevitServices.Persistence import DocumentManager from RevitServices.Transactions import TransactionManager # the current document doc = DocumentManager.Instance.CurrentDBDocument
The second part, the input linked document store in the linkdoc variable. And copy the grids and levels by using FilteredElementCollector class. FilteredElementCollector has three Constructors (see figure – 1.1 screenshot from revitapidocs). We will be using the first Constructor which has only one argument as a document.

And applied OfClass method to collect the elements which belong to the specific class. In this case, Level class and Grid class. After that combine, the grid and the level elements list into a single list variable named collector. Collect these element’s Id and store in .Net type List ids variable. Start the transaction.
# input link document linkdoc = UnwrapElement(IN[0]) # collect grids from the link document collector = FilteredElementCollector(linkdoc).OfClass(Grid).ToElements() # collect levels from the link document levels = FilteredElementCollector(linkdoc).OfClass(Level).ToElements() # convert python list collector = list(collector) # grid list combine with level list collector.extend(levels) # dot-net elementId list ids = List[ElementId]([i.Id for i in collector]) # transaction start TransactionManager.Instance.EnsureInTransaction(doc) #copy template from link-doc to current-doc copied_elements = ElementTransformUtils.CopyElements(linkdoc,ids,doc,Transform.Identity,CopyPasteOptions()) # transaction done TransactionManager.Instance.TransactionTaskDone() # get elements from ids elements = [doc.GetElement(i) for i in copied_elements] # output OUT = elements
ElementTransformUtils Class has CopyElements method which can copy a set of elements from document to document. See figure – 1.2 and 1.3.


Use doc.GetElement instance method to returns output values to copied elements.
Here is sample usage and the complete code is below.
import clr,System clr.AddReference("RevitServices") clr.AddReference("RevitAPI") from Autodesk.Revit.DB import * from System.Collections.Generic import List from RevitServices.Persistence import DocumentManager from RevitServices.Transactions import TransactionManager # current document doc = DocumentManager.Instance.CurrentDBDocument # input link document linkdoc = UnwrapElement(IN[0]) # collect grids from the link document collector = FilteredElementCollector(linkdoc).OfClass(Grid).ToElements() # collect levels from the link document levels = FilteredElementCollector(linkdoc).OfClass(Level).ToElements() # convert python list collector = list(collector) # grid list combine with level list collector.extend(levels) # dot-net elementId list ids = List[ElementId]([i.Id for i in collector]) # transaction start TransactionManager.Instance.EnsureInTransaction(doc) #copy elements from link-doc to current-doc copied_elements = ElementTransformUtils.CopyElements(linkdoc,ids,doc,Transform.Identity,CopyPasteOptions()) # transaction done TransactionManager.Instance.TransactionTaskDone() # get elements from ids elements = [doc.GetElement(i) for i in copied_elements] # output OUT = elements
Hi Mi,
Can your useful Dynamo nodes be download, I can’t seem to find them using the Online Package Search within Revit Dynamo.
Rob
LikeLike
The package name is ” Quasar ” and node name is ” CopyLevelAndGridFromLinkFile ” .
LikeLike
Thanks, Min, I actually just found it! Thanks
LikeLike
I’m not working. I can’t find copy level and grid from link file.
Quaser have just copy level and grid from link document. but it doesn’t make this.
dynamo file upload please.
LikeLike