# # Revit Batch Processor # # Copyright (c) 2019 Dan Rumery, BVN # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # # import clr import System import System.Windows clr.AddReference("System.Core") clr.ImportExtensions(System.Linq) clr.AddReference("RevitAPI") clr.AddReference("RevitAPIUI") from Autodesk.Revit.DB import * from Autodesk.Revit.DB.Analysis import * from Autodesk.Revit.UI import * from Autodesk.Revit.DB import Transaction import revit_script_util from revit_script_util import Output sessionId = revit_script_util.GetSessionId() uiapp = revit_script_util.GetUIApplication() # NOTE: these only make sense for batch Revit file processing mode. doc = revit_script_util.GetScriptDocument() revitFilePath = revit_script_util.GetRevitFilePath() projectFolderName = revit_script_util.GetProjectFolderName() #My Default Variables syncOpts = SynchronizeWithCentralOptions() transOpts= TransactWithCentralOptions() def alert(msg): TaskDialog.Show('pyRevit', msg) def quit(): __window__.Close() #Creating collector and Getting all RvtLinks link_collector = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_RvtLinks)\ .WhereElementIsElementType() \ .ToElements() #Storing Reference Type in Variable reference_types = 0.0 #Starting the Set Transaction t = Transaction(doc, "Change Reference Types") t.Start() for link in link_collector: reference_types = link.LookupParameter('Reference Type') if reference_types: reference_types.Set(2) #Commiting the Set Transaction t.Commit() doc.SynchronizeWithCentral(transOpts, syncOpts)