I have a lot of models to upgrade to 2021, and i already have a script to open and save all the files out, the only issue that all the linked models (some models have upwards of 20) also load and take up time to convert. When we compound this with the fact that the version must be appended to our file name we have quite the slowdown.
Can I get a file to essentially unload all its links as it opens?
if you want to hurt my feelings and not use Rhythm
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
def UnloadRevitLinks(path):
mPath = FilePath(path)
tData = TransmissionData.ReadTransmissionData(mPath)
#collect all (immediate) external references in the model
externalReferences = tData.GetAllExternalFileReferenceIds()
for refId in externalReferences:
extRef = tData.GetLastSavedReferenceData(refId)
if extRef.ExternalFileReferenceType == ExternalFileReferenceType .RevitLink:
tData.SetDesiredReferenceData(refId, extRef.GetPath(), extRef.PathType, False)
#make sure the IsTransmitted property is set
tData.IsTransmitted = True
#modified transmission data must be saved back to the model
TransmissionData.WriteTransmissionData(mPath, tData);
return path
#the model paths
modelPaths = UnwrapElement(IN[0])
#return the results
if isinstance(IN[0], list): OUT = [UnloadRevitLinks(x) for x in modelPaths]
else: OUT = UnloadRevitLinks(modelPaths)
This is the Python i was testing out before. Note that it runs from any version of Revit on any other supported file versions (ie: if you’re in 2019 you can modify 2022 files, and vice versa) because it doesn’t require opening the document. Includes some UI to select the file and allows unloading or loading of all RVTs or all CAD files.
I have not tried it in the BIM360 environment yet.
(actually attached the dyn this time) Set Reference Load State.dyn (12.0 KB)