Bind Links with Dynamo (for IFC Export)

Has anyone managed to select all linked Revit models and Bind them to the active project file?

I’ve been scouring the SDK to see if we even have access to this ability.

Let me explain my desired result: Batch exported IFC files for use in Solibri. My goal is to have the end users run a graph that will automatically export the project file and all of its links.

I have been using this closed topic as a guide:

Export to dwf or IFC via dynamo?

Here is the Python Code:

> #python nodes in dynamo 0.7
> #proposed by Nicklas Verdier Østergaard,
> #Based on tools.dwf by Julien Benoit @jbenoit44
> #
> import clr
> clr.AddReference('ProtoGeometry')
> from Autodesk.DesignScript.Geometry import *
> # Import ToDSType(bool) extension method
> clr.AddReference("RevitNodes")
> import Revit
> clr.ImportExtensions(Revit.Elements)
> # Import geometry conversion extension methods
> clr.ImportExtensions(Revit.GeometryConversion)
> # Import DocumentManager and TransactionManager
> clr.AddReference("RevitServices")
> import RevitServices
> from RevitServices.Persistence import DocumentManager
> from RevitServices.Transactions import TransactionManager
> from System.Collections.Generic import *
> # Import RevitAPI
> clr.AddReference("RevitAPI")
> import Autodesk
> from Autodesk.Revit.DB import *

> doc = DocumentManager.Instance.CurrentDBDocument
> uiapp = DocumentManager.Instance.CurrentUIApplication
> app = uiapp.Application
> uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument

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

> folder=UnwrapElement(IN[0])
> name=UnwrapElement(IN[1])
> fileversion = IN[2]
> wallandcolumnsplitting = IN[3]
> exportbasequantities = IN[4]
> view = UnwrapElement(IN[5])

> #IFCVersion=UnwrapElement(IN[2])

> # Start Transaction
> TransactionManager.Instance.EnsureInTransaction(doc)
> total_export = []

> for i,v in enumerate(view):
> 	options=IFCExportOptions()
> 	#if fileversion != None:
> 	#	options.FileVersion = fileversion
> 	if fileversion == "IFC4":
> 		options.FileVersion = IFCVersion.IFC4
> 	if fileversion == "IFC2x2":
> 		options.FileVersion = IFCVersion.IFC2x2
> 	if fileversion == "IFC2x3":
> 		options.FileVersion = IFCVersion.IFC2x3
> 	if fileversion == "IFC2x3":
> 		options.FileVersion = IFCVersion.IFC2x3CV2
> 	if fileversion == "IFCBCA":
> 		options.FileVersion = IFCVersion.IFCBCA
> 	if fileversion == "IFCCOBIE":
> 		options.FileVersion = IFCVersion.IFCCOBIE
> 	if fileversion == "":
> 		options.FileVersion = IFCVersion.Default
> 	options.WallAndColumnSplitting = wallandcolumnsplitting
> 	options.ExportBaseQuantities = exportbasequantities
> 	options.FilterViewId = v.Id

> #IFCVersion Version = (IFCVersion) Enum.Parse( typeof(IFCVersion), UnwrapElement(IN[2]), true );
> #x.FileVersion = IFCVersion.IFC2x3CV2

> 	c=doc.Export(folder, name[i], options)
> 	total_export.append(c)

> # End Transaction
> TransactionManager.Instance.TransactionTaskDone()

> if fileversion == "":
> 	OUT="Default settings used"
> else:
> 	OUT=total_export

This works very well, but I wanted to access the “Export Linked Files as Separate IFCs” toggle also.

Using the data over at SourceForge, I tried to adapt the Python Script to include this toggle but could not seem to get it to work.

So I tried taking a step back. What if my template has a preset IFC Export setup, in which all of the settings I need are toggled, and then dynamo only needs me to select this setup.

Couldn’t figure out how to do this either.

It turns out that this toggle does not even do what I wanted. It basically opens the linked files and exports from there, ignoring my visibility settings and toggle for “export only elements visible in view”

So I thought, fine, what if I bind the linked files first?

My template would have 3D views preset up with a “_3D4IFC” prefix. Each view would correspond to a discipline and show only their elements (structural, mechanical, etc.). The dynamo graph looks for that prefix and exports an IFC file for each view, separated by discipline. This gives me ultimate control over what transfers and what doesn’t, without messing with IFC translation files. It would also disregard any misaligned origins between my model and the link, saving me time in correcting Project/Survey base points.

This is where I’m stuck. If you have any ideas, I’d love to hear them. If you have a different approach, I’d also like to hear that.



If binding links are not exposed in the API you could try to use this method:


I tried this with ID_BIND_LINK_AS_GROUP, which I found in my journal, but no joy.

“The commandId must be in Autodesk.Revit.UI.PostableCommand or an external command.”

Hi Dan!

This script is very useful.

I would like to know if you could complete it. I would be very interested in you sharing the final solution