Links - "Reload From..."


#1

Hey everyone,

I’m trying to automatically reload some links in the central model because the file path has been changed so Revit is not able to find the files anymore and I have to tell it the new path.

Ideally, I’d put all the files to be linked in a folder and use the name of the file as the hook for Revit to recognise its links.

I can’t see any node that does the “Reload From…” action. Are you aware of anything to do that?

Cheers,

Andrea


From Directory Open / Remove all DWG links / Reload all RVT links / Save as Central
#2

RevitLinkType has a method LoadFrom that will reload links from a file path. You can create file paths for each link by appending the link name to a specified folder that houses the new links.
http://www.revitapidocs.com/2018/bdb3a91e-9a0a-e68d-51da-c460535f5fd2.htm


#3

Thanks @Nick_Boyts

That sounds like what I’m trying to do but unfortunately I’m not really Python literate…Do you think you can help me?

Thanks!


#4

I happen to have just created a workflow for this exact scenario so I do have a bit of code that will work. In general, you need to make an attempt before expecting anyone to help with your queries. I would also highly recommend getting familiar with Python.

#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)
linkInstances = collector.OfClass(Autodesk.Revit.DB.RevitLinkInstance)
folderpath = IN[0]
reloadedlinks = []
for i in linkInstances:
	name = i.Name
	path = folderpath + "\\" + name
	path = path.rsplit(' : ',2)[0]
	filepath = FilePath(path)
	RevitLinkType  = doc.GetElement(i.GetTypeId())
	RevitLinkType.LoadFrom(filepath,None)
	reloadedlinks.append(RevitLinkType)
OUT= reloadedlinks

I used one of Nicklas Østertgaard’s nodes as a template for getting the link types because inputting the RevitLinkType directly doesn’t seem to work - so thank you to Nicklas.


#5

Hey @Nick_Boyts ,

Thank you! It works beautifully!!

You’re absolutely right on the Python side. I’m actually trying to get my head around Python but I find the learning curve pretty steep as I can’t find much documentation that explains the process from the beginning (i.e. something that explains the initial import of the modules, which ones to import and when, unwrapping the elements, etc.). I did an online course that gave me the basics on the language but now I’m struggling on applying that to Revit.
Anyways, now I’m a bit familiar with that, but just to the level that I can copy and modify scripts that I find online. Starting one from scratch is still out of my range.

Thank you!


#6

HI how do exactly will i use this code?


#7

This is a good place to start:

I’ve found you really don’t need to know a lot about python to get things working. The more you know the more efficient your code can be for sure, but you can definitely get by with the basics in most situations. Just try to get familiar with the Revit API and what the standard modules include. Unwrapping elements basically just converts them from the Dynamo type to the Revit type. You can’t use a Revit method on a Dynamo object so it has to be unwrapped.