Skip to content

Commit 00bf08c

Browse files
committed
Walls are now dynamically voided when joining, so you can join/unjoin voided walls
1 parent 3bb3a80 commit 00bf08c

3 files changed

Lines changed: 35 additions & 17 deletions

File tree

src/blenderbim/blenderbim/bim/module/model/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
classes = (
55
product.AddTypeInstance,
66
product.AlignProduct,
7+
product.DynamicallyVoidProduct,
78
workspace.Hotkey,
89
wall.JoinWall,
910
wall.AlignWall,

src/blenderbim/blenderbim/bim/module/model/product.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,37 @@ def get_axis_distances(self, point, axis, context):
120120
return results
121121

122122

123+
class DynamicallyVoidProduct(bpy.types.Operator):
124+
bl_idname = "bim.dynamically_void_product"
125+
bl_label = "Dynamically Void Product"
126+
bl_options = {"REGISTER", "UNDO"}
127+
obj: bpy.props.StringProperty()
128+
129+
def execute(self, context):
130+
obj = bpy.data.objects.get(self.obj)
131+
product = IfcStore.get_file().by_id(obj.BIMObjectProperties.ifc_definition_id)
132+
if not product.HasOpenings:
133+
return {"FINISHED"}
134+
if [m for m in obj.modifiers if m.type == "BOOLEAN"]:
135+
return {"FINISHED"}
136+
representation = ifcopenshell.util.representation.get_representation(product, "Model", "Body", "MODEL_VIEW")
137+
if not representation:
138+
return {"FINISHED"}
139+
was_edit_mode = obj.mode == "EDIT"
140+
if was_edit_mode:
141+
bpy.ops.object.mode_set(mode="OBJECT")
142+
bpy.ops.bim.switch_representation(
143+
obj=obj.name,
144+
should_switch_all_meshes=True,
145+
should_reload=True,
146+
ifc_definition_id=representation.id(),
147+
disable_opening_subtractions=True,
148+
)
149+
if was_edit_mode:
150+
bpy.ops.object.mode_set(mode="EDIT")
151+
return {"FINISHED"}
152+
153+
123154
def generate_box(usecase_path, ifc_file, settings):
124155
box_context = ifcopenshell.util.representation.get_context(ifc_file, "Model", "Box", "MODEL_VIEW")
125156
if not box_context:

src/blenderbim/blenderbim/bim/module/model/wall.py

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -33,23 +33,7 @@ def mode_callback(obj, data):
3333
parametric = ifcopenshell.util.element.get_psets(product).get("EPset_Parametric")
3434
if not parametric or parametric["Engine"] != "BlenderBIM.DumbWall":
3535
return
36-
if product.HasOpenings:
37-
if [m for m in obj.modifiers if m.type == "BOOLEAN"]:
38-
continue
39-
representation = ifcopenshell.util.representation.get_representation(
40-
product, "Model", "Body", "MODEL_VIEW"
41-
)
42-
if not representation:
43-
continue
44-
bpy.ops.object.mode_set(mode='OBJECT')
45-
bpy.ops.bim.switch_representation(
46-
obj=obj.name,
47-
should_switch_all_meshes=True,
48-
should_reload=True,
49-
ifc_definition_id=representation.id(),
50-
disable_opening_subtractions=True,
51-
)
52-
bpy.ops.object.mode_set(mode='EDIT')
36+
bpy.ops.bim.dynamically_void_product(obj=obj.name)
5337
IfcStore.edited_objs.add(obj)
5438
bm = bmesh.from_edit_mesh(obj.data)
5539
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):
10387

10488
def execute(self, context):
10589
selected_objs = context.selected_objects
90+
for obj in selected_objs:
91+
bpy.ops.bim.dynamically_void_product(obj=obj.name)
10692
if len(selected_objs) == 0:
10793
return {"FINISHED"}
10894
if not self.join_type:

0 commit comments

Comments
 (0)