New recalculate wall operator to manually trigger an update of all wall connections

This commit is contained in:
Dion Moult
2022-09-18 15:57:07 +10:00
parent cd930d809a
commit 7f76488869
2 changed files with 29 additions and 0 deletions
@@ -30,6 +30,7 @@ classes = (
wall.AlignWall,
wall.FlipWall,
wall.SplitWall,
wall.RecalculateWall,
opening.AddElementOpening,
profile.ExtendProfile,
prop.BIMModelProperties,
@@ -185,6 +185,20 @@ class SplitWall(bpy.types.Operator):
return {"FINISHED"}
class RecalculateWall(bpy.types.Operator):
bl_idname = "bim.recalculate_wall"
bl_label = "Recalculate Wall"
bl_options = {"REGISTER", "UNDO"}
@classmethod
def poll(cls, context):
return context.selected_objects
def execute(self, context):
DumbWallRecalculator().recalculate(context.selected_objects)
return {"FINISHED"}
def recalculate_dumb_wall_origin(wall, new_origin=None):
if new_origin is None:
new_origin = wall.matrix_world @ Vector(wall.bound_box[0])
@@ -369,6 +383,20 @@ class DumbWallAligner:
return round(degrees(angle) % 360) == 180
class DumbWallRecalculator:
def recalculate(self, walls):
queue = set()
for wall in walls:
element = tool.Ifc.get_entity(wall)
queue.add((element, wall))
for rel in getattr(element, "ConnectedTo", []):
queue.add((rel.RelatedElement, tool.Ifc.get_object(rel.RelatedElement)))
for rel in getattr(element, "ConnectedFrom", []):
queue.add((rel.RelatingElement, tool.Ifc.get_object(rel.RelatingElement)))
joiner = DumbWallJoiner()
for element, wall in queue:
if wall:
joiner.recreate_wall(element, wall)
class DumbWallGenerator: