I am trying to write an exception to problematic Revit room geometry within a python node.
The goal is to extract room solids where possible, and for the exception to produce a list where rooms that will cause the script to run with errors because of geometry issues are highlighted, along with the groups containing those rooms. This will allow the usable rooms to be included in the rest of the script, and provide an output report identifying the elements needing addressing by anyone unfamiliar with error checking in Dynamo.
At the moment when the script runs into problematic geometry (i.e. trim_edge_loops, strangely shaped rooms, overlapping boundaries etc.) it causes Dynamo and Revit to crash. But these are the elements I’m looking to identify and list
Here is the node:
And the code:
import clr clr.AddReference("RevitAPI") import Autodesk from Autodesk.Revit.DB import * clr.AddReference("RevitServices") import RevitServices from RevitServices.Persistence import DocumentManager from RevitServices.Transactions import TransactionManager clr.AddReference("RevitNodes") import Revit clr.ImportExtensions(Revit.Elements) clr.ImportExtensions(Revit.GeometryConversion) clr.AddReference('ProtoGeometry') from Autodesk.DesignScript.Geometry import * doc = DocumentManager.Instance.CurrentDBDocument rooms = IN lines = IN #families contained in rooms groups = IN #groups containing families solids =  problemGeomRooms, problemGeomGroups = ,  linesOut, roomsOut, groupsOut = , ,  for e, r in enumerate(rooms): rm = UnwrapElement(r) results = SpatialElementGeometryCalculator(doc).CalculateSpatialElementGeometry(rm) if results: try: roomSolid = results.GetGeometry().ToProtoType() solids.append(roomSolid) roomsOut.append(r) linesOut.append(lines[e]) groupsOut.append(groups[e]) except: problemGeomRooms.append(r) problemGeomGroups.append(groups[e]) pass OUT = roomsOut, linesOut, groupsOut, solids, problemGeomRooms, problemGeomGroups
Any help much appreciated. Thanks