Batch reload linked model from dynamo

Dear Gents,

I’m trying to write a dynamo to batch reload the linked model from a folder. I have studied the one by Nick_Boyts https://forum.dynamobim.com/t/links-reload-from/13224

It works only if the folder itself contains all files which are linked to the mode. The error would happen when one file is missing in the folder. And the case is it is usually I do not receive all updated model from other parties.
image
I tried to use try: except to bypass the message, but no luck it is not working. Does anyone have an idea for that?

for i in linkInstances:
try:
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)
except:
pass

Hi @chengcwy,

You should modify the position of the try / except statement :

for i in linkInstances:
		name = i.Name
		path = folderpath + "\\" + name
		paths = path.rsplit(' : ',2)[0]
		filepath = FilePath(paths)
		RevitLinkType=doc.GetElement(i.GetTypeId())
		try:
			RevitLinkType.LoadFrom(filepath,None)
		except:
			pass
		reloadedlinks.append(RevitLinkType)

OUT= reloadedlinks
3 Likes

It totally works. Credit for you, sir.