Walls are now dynamically voided when joining, so you can join/unjoin voided walls

This commit is contained in:
Dion Moult
2021-08-04 20:45:46 +10:00
parent 3bb3a8018a
commit 00bf08c220
3 changed files with 35 additions and 17 deletions
@@ -4,6 +4,7 @@ from . import handler, prop, ui, grid, product, wall, slab, stair, door, window,
classes = (
product.AddTypeInstance,
product.AlignProduct,
product.DynamicallyVoidProduct,
workspace.Hotkey,
wall.JoinWall,
wall.AlignWall,
@@ -120,6 +120,37 @@ class AlignProduct(bpy.types.Operator):
return results
class DynamicallyVoidProduct(bpy.types.Operator):
bl_idname = "bim.dynamically_void_product"
bl_label = "Dynamically Void Product"
bl_options = {"REGISTER", "UNDO"}
obj: bpy.props.StringProperty()
def execute(self, context):
obj = bpy.data.objects.get(self.obj)
product = IfcStore.get_file().by_id(obj.BIMObjectProperties.ifc_definition_id)
if not product.HasOpenings:
return {"FINISHED"}
if [m for m in obj.modifiers if m.type == "BOOLEAN"]:
return {"FINISHED"}
representation = ifcopenshell.util.representation.get_representation(product, "Model", "Body", "MODEL_VIEW")
if not representation:
return {"FINISHED"}
was_edit_mode = obj.mode == "EDIT"
if was_edit_mode:
bpy.ops.object.mode_set(mode="OBJECT")
bpy.ops.bim.switch_representation(
obj=obj.name,
should_switch_all_meshes=True,
should_reload=True,
ifc_definition_id=representation.id(),
disable_opening_subtractions=True,
)
if was_edit_mode:
bpy.ops.object.mode_set(mode="EDIT")
return {"FINISHED"}
def generate_box(usecase_path, ifc_file, settings):
box_context = ifcopenshell.util.representation.get_context(ifc_file, "Model", "Box", "MODEL_VIEW")
if not box_context:
@@ -33,23 +33,7 @@ def mode_callback(obj, data):
parametric = ifcopenshell.util.element.get_psets(product).get("EPset_Parametric")
if not parametric or parametric["Engine"] != "BlenderBIM.DumbWall":
return
if product.HasOpenings:
if [m for m in obj.modifiers if m.type == "BOOLEAN"]:
continue
representation = ifcopenshell.util.representation.get_representation(
product, "Model", "Body", "MODEL_VIEW"
)
if not representation:
continue
bpy.ops.object.mode_set(mode='OBJECT')
bpy.ops.bim.switch_representation(
obj=obj.name,
should_switch_all_meshes=True,
should_reload=True,
ifc_definition_id=representation.id(),
disable_opening_subtractions=True,
)
bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.bim.dynamically_void_product(obj=obj.name)
IfcStore.edited_objs.add(obj)
bm = bmesh.from_edit_mesh(obj.data)
bmesh.ops.dissolve_limit(bm, angle_limit=pi / 180 * 1, verts=bm.verts, edges=bm.edges)
@@ -103,6 +87,8 @@ class JoinWall(bpy.types.Operator):
def execute(self, context):
selected_objs = context.selected_objects
for obj in selected_objs:
bpy.ops.bim.dynamically_void_product(obj=obj.name)
if len(selected_objs) == 0:
return {"FINISHED"}
if not self.join_type: