GNU General Public License for more details. See this link for a copy of the GNU General Public License protecting this package. https://github.com/eirannejad/pyRevit/blob/master/LICENSE ''' from Autodesk.Revit.DB import ModelPathUtils, TransmissionData, RevitLinkType, ElementType import clr uidoc = __revit__.ActiveUIDocument doc = __revit__.ActiveUIDocument.Document # selection = [ doc.GetElement( elId ) for elId in __revit__.ActiveUIDocument.Selection.GetElementIds() ] location = doc.PathName try: modelPath = ModelPathUtils.ConvertUserVisiblePathToModelPath( location ) transData = TransmissionData.ReadTransmissionData( modelPath ) externalReferences = transData.GetAllExternalFileReferenceIds() for refId in externalReferences: extRef = transData.GetLastSavedReferenceData( refId ) if 'CADLink' == str( extRef.ExternalFileReferenceType ): link = doc.GetElement( refId ) # link = clr.Convert( link, ElementType ) path = ModelPathUtils.ConvertModelPathToUserVisiblePath( extRef.GetPath() ) if '' == path: path = '--NOT ASSIGNED--' print( "Reloading...\n{0}{1}".format( str( str( extRef.ExternalFileReferenceType )+':').ljust(20), path )) # link.Reload() # print('Done\n') print('Revit API does not have a CADLinkType.Reload method yet') except: print('Model is not saved yet. Can not aquire location.')
if not model.endswith(".rvt"): skip_counter[model] = "not_a_rvt_model" continue elif model in skip_models: skip_counter[model] = "model_in_skip_list" continue elif model.endswith("0001.rvt"): skip_counter[model] = "model_is_a_backup_file" continue rvt_models.add(model) for model in rvt_models: print("\n\n" + 18 * "-+-" + model) model_path = os.path.join(relink_dir, model) rvt_model_path = FilePath(model_path) tm_data = TransmissionData.ReadTransmissionData(rvt_model_path) if not tm_data: continue ext_refs = tm_data.GetAllExternalFileReferenceIds() for ext_ref_id in ext_refs: target_rvt_path = None desired_user_path = None print(55 * "-") print(ext_ref_id.IntegerValue) relink_for_ref_type(ext_ref_id, ref_types, relink_map) tm_data.IsTransmitted = True TransmissionData.WriteTransmissionData(rvt_model_path, tm_data)