Batch link in Revit models

Link in all Revit models in a folder

I’m trying to use Dynamo to batch link in all Revit models from a file (load new, not reload) for when I have dozens of Revit models that need to be linked into a master file. Assuming that all the Revit models are in the same folder, I was trying to adapt the method and Python script from this post which reloads all Revit links from a folder: Links - "Reload From...".

It’ll successfully load in one of the models, but it will fail on the second Revit model and throw the error:
Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed.
Traceback (most recent call last):
File “”, line 44, in
AttributeError: ‘RevitLinkInstance’ object has no attribute ‘LoadFrom’

Another question I had is whether there is a way to specify whether the model is loaded in center to center, origin to origin, with shared coordinates, etc.

Thanks!

#python nodes in dynamo 1.0.0
#originally by Nicklas Østertgaard nvo@bimshark.com / nvo@shl.fk

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
collector = Autodesk.Revit.DB.FilteredElementCollector(doc)

folderContents = IN[0]
directoryPath = IN[1]
reloadedlinks = []
TransactionManager.Instance.EnsureInTransaction(doc)
options = RevitLinkOptions(False)

for file in folderContents:
ModelPath = ModelPathUtils.ConvertUserVisiblePathToModelPath(file)
newLinkType = RevitLinkType.Create(doc, ModelPath, options)
instance = RevitLinkInstance.Create(doc, newLinkType.ElementId)

instance.LoadFrom(ModelPath, None)

reloadedlinks.append(RevitLinkType)

TransactionManager.Instance.TransactionTaskDone()

OUT = 0

I have just made this release…

in this is nodes for linking documents included

Hi @polystyrene,

Welcome to the dynamo forum.

The Morpheus package has already the nodes you are looking for with the options center to center, origin to origin and shared coordinates.

3 Likes

Dear @Alban_de_Chasteigner,

I have tried to use these nodes, but the nodes return “Function” and no-link in load in the opened project. I am using Revit 2020 and Dynamo 2.1.0.

Please, find attached dyn file:
Cargar Links Masiva.dyn

Any idea???

Hi,

Make sure that the Default Value is checked (with right-click).
When the node is totally light grey, it means that an input is missing.


Many thnaks for your prompt response @Alban_de_Chasteigner

However, I can not select with right click “Use Default Value” in node input “ClosedWorsetNamesContain_optinonal” since, as seen in the image, there are not any default value defined inside custom node.

What is the default value that should be define inside custom node? Or could you share DYN file that you did in your second image?

Many thanks for your help

I have a sligthly different version.

You can update the Morpheus package or maybe add the missing = None in the dyf file.

1 Like

Many thanks Alban. Now, it is solved and everything works right

Sorry to resurrect this thread, i cannot use Morpheus package as I am running v1.3 of Dynamo.

Can i have the Phyton Script instead so i can recreate the node. Link Model via Shared Coordinates?