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?

Hi!

I contemplated, creating a new topic for this, but there still might be some interest in this here, so I’m trying instead of flooding with very similar questions. If there are no responses I might create a separate thread.

I wish to do something similar to this, but instead of the workflow described here in this topic and summarized below:

  • “I have many revit projects - I wish to link them all into one project quickly”
    The situation being that there is a “main file” and a lot of projects (list) needs to be linked into this main file.

Instead I wish to link one project containing few identifying elements into many project files. The reason could be to visually be able to compare them in different ways.
Therefore the situation is:

  • “I have many revit projects - I wish to link one specific project into each separate project and save”
    So I need a list of projects and a path to one specific project and a way to open all the projects from the list, and link the project in the specific path into each.

Both Zhukoven and the Morpheus packages has tools that link a lot of files into the open files. But is it possible to do as described with these tools or is there something else out there that can help?

Added note:
Ideally I would like to bind the single linked project into each project file - however it seems this is impossible through dynamo - so perhaps the different “copy/insert” workflows that are in the forums might help - This is not the main part at this moment however :slight_smile:

It has been a while since I fiddled with Dynamo, so apologies if I’m missing something very obvious.

Thanks a lot,

Hi @Revit_Noob were you able to solve this? I tried this but i cannot seem to make it work. I am using Revit 2020 at the moment

We have the same problem i cannot find the 3rd line how did you solve this? This is what mine said "document already contains a linked model at path path.

parameter name: path"