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
from Autodesk.Revit.DB import *
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
#the model paths
modelPaths = UnwrapElement(IN)
#return the results
if isinstance(IN, 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.