Hi all, I have a model health script that I have been running for a while. I am pulling over 100 metrics from Revit and everything has been relatively working fine except for one section (MEP connectors).
The goal of this section is to identify open-ended MEP elements that will mess with flow calculation and other things. My solution, I think is relatively simple. Grab specified elements, get all connectors on said element, and check to see if the connector is connected or not (I do understand links play a part here).
The problem is that it crashes Revit. In my testing on my personal computer, I have found that implementing a time.sleep of 0.1 seconds for every 25 elements processed prevents the crash. My best guess is that I am processing elements quicker than Revit can handle but I am not sure. My company recently got an impressive cloud computer and some files are crashing on it. I reduced the pause from 25 elements down to 20 so it will trigger the pause more frequently and this solves the problem for the cloud computer but increases the time to completion.
I have tested and noted this behavior in Revit Vessions from 2018 through 2023.
Do any of you have an idea what the problem could be or a better solution than implementing a pause?
categorieFilter = ['OST_CableTray','OST_CableTrayFitting','OST_Conduit','OST_ConduitFitting','OST_DuctCurves',
'OST_FlexDuctCurves', 'OST_DuctFitting','OST_DuctTerminal','OST_ElectricalEquipment','OST_ElectricalFixtures',
'OST_LightingDevices','OST_LightingFixtures','OST_MechanicalEquipment','OST_PipeCurves','OST_FlexPipeCurves',
'OST_PipeFitting','OST_PlumbingFixtures','OST_SpecialityEquipment','OST_Sprinklers']
categorieFilter = rvt.getBuiltInCategory(categorieFilter)
categorieFilter = List[BuiltInCategory](categorieFilter) # sets the list up for the .net framwork
categorieFilter = ElementMulticategoryFilter(categorieFilter,False) # creates the filter (True value will remove Items from the selction)
#try:
allElements = FilteredElementCollector(doc).WhereElementIsNotElementType().WherePasses(categorieFilter).ToElements()
connectorsCount, unconnectedCount = 0, 0
notConnected = []
for count, element in enumerate(allElements):
if count % 25 == 0:
time.sleep(0.1)
try:
connectors = element.MEPModel.ConnectorManager.Connectors
except:
try:
connectors = element.ConnectorManager.Connectors
except:
continue
added, typeAdded= True, []
for connector in connectors:
connectorsCount += 1
try:
if not connector.IsConnected:
conType = connector.Domain
unconnectedCount += 1
if added or conType not in typeAdded:
notConnected.append(element.Name)
added = False
typeAdded.append(conType)
conType = str(conType).replace('Domain','')
csvRow(elementsCSV,("connectedConnector", element.Id, element.Name, conType, '', fileName))
except:
pass
Thank you,
Steven