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.

2 Likes