Editing voids or dumb walls now auto enable dynamic voids, so openings work well with them.

This commit is contained in:
Dion Moult
2021-07-25 14:06:49 +10:00
parent 07f19ad80a
commit c00bcc78e9
3 changed files with 45 additions and 5 deletions
@@ -1,6 +1,8 @@
import bpy
import bmesh
import blenderbim.bim.handler
import ifcopenshell
import ifcopenshell.util.representation
from blenderbim.bim.ifc import IfcStore
from math import pi
from bpy.types import Operator
@@ -13,7 +15,7 @@ def element_listener(element, obj):
def mode_callback(obj, data):
for obj in bpy.context.selected_objects + [bpy.context.active_object]:
for obj in set(bpy.context.selected_objects + [bpy.context.active_object]):
if (
obj.mode != "EDIT"
or not obj.data
@@ -25,6 +27,24 @@ def mode_callback(obj, data):
product = IfcStore.get_file().by_id(obj.BIMObjectProperties.ifc_definition_id)
if not product.is_a("IfcOpeningElement"):
return
for rel in product.VoidsElements:
building_element_obj = IfcStore.get_element(rel.RelatingBuildingElement.id())
if not building_element_obj:
continue
if [m for m in building_element_obj.modifiers if m.type == "BOOLEAN"]:
continue
representation = ifcopenshell.util.representation.get_representation(
rel.RelatingBuildingElement, "Model", "Body", "MODEL_VIEW"
)
if not representation:
continue
bpy.ops.bim.switch_representation(
obj=building_element_obj.name,
should_switch_all_meshes=True,
should_reload=True,
ifc_definition_id=representation.id(),
disable_opening_subtractions=True,
)
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)
@@ -20,7 +20,7 @@ def element_listener(element, obj):
def mode_callback(obj, data):
for obj in bpy.context.selected_objects + [bpy.context.active_object]:
for obj in set(bpy.context.selected_objects + [bpy.context.active_object]):
if (
obj.mode != "EDIT"
or not obj.data
@@ -33,7 +33,28 @@ 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')
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)
bmesh.update_edit_mesh(obj.data)
bm.free()
class AddWallOpening(bpy.types.Operator):
@@ -37,6 +37,7 @@ class BimTool(WorkSpaceTool):
row.prop(props, "relating_type", text="")
row.label(text="", icon="BLANK1")
row = layout.row(align=True)
row.label(text="", icon="EVENT_SHIFT")
row.label(text="Add Type Instance", icon="EVENT_A")
@@ -54,8 +55,6 @@ class BimTool(WorkSpaceTool):
row.label(text="", icon="EVENT_SHIFT")
row.label(text="Mitre", icon="EVENT_Y")
row = layout.row(align=True)
row.label(text="Wall Tools")
row = layout.row(align=True)
@@ -86,11 +85,11 @@ class BimTool(WorkSpaceTool):
row.label(text="Align Interior", icon="EVENT_V")
row = layout.row(align=True)
row = layout.row(align=True)
row.label(text="", icon="EVENT_ALT")
row.label(text="Opening", icon="EVENT_O")
class Hotkey(bpy.types.Operator):
bl_idname = "bim.hotkey"
bl_label = "Hotkey"