mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-26 02:07:36 +00:00
Walls are now dynamically voided when joining, so you can join/unjoin voided walls
This commit is contained in:
@@ -4,6 +4,7 @@ from . import handler, prop, ui, grid, product, wall, slab, stair, door, window,
|
|||||||
classes = (
|
classes = (
|
||||||
product.AddTypeInstance,
|
product.AddTypeInstance,
|
||||||
product.AlignProduct,
|
product.AlignProduct,
|
||||||
|
product.DynamicallyVoidProduct,
|
||||||
workspace.Hotkey,
|
workspace.Hotkey,
|
||||||
wall.JoinWall,
|
wall.JoinWall,
|
||||||
wall.AlignWall,
|
wall.AlignWall,
|
||||||
|
|||||||
@@ -120,6 +120,37 @@ class AlignProduct(bpy.types.Operator):
|
|||||||
return results
|
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):
|
def generate_box(usecase_path, ifc_file, settings):
|
||||||
box_context = ifcopenshell.util.representation.get_context(ifc_file, "Model", "Box", "MODEL_VIEW")
|
box_context = ifcopenshell.util.representation.get_context(ifc_file, "Model", "Box", "MODEL_VIEW")
|
||||||
if not box_context:
|
if not box_context:
|
||||||
|
|||||||
@@ -33,23 +33,7 @@ def mode_callback(obj, data):
|
|||||||
parametric = ifcopenshell.util.element.get_psets(product).get("EPset_Parametric")
|
parametric = ifcopenshell.util.element.get_psets(product).get("EPset_Parametric")
|
||||||
if not parametric or parametric["Engine"] != "BlenderBIM.DumbWall":
|
if not parametric or parametric["Engine"] != "BlenderBIM.DumbWall":
|
||||||
return
|
return
|
||||||
if product.HasOpenings:
|
bpy.ops.bim.dynamically_void_product(obj=obj.name)
|
||||||
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)
|
IfcStore.edited_objs.add(obj)
|
||||||
bm = bmesh.from_edit_mesh(obj.data)
|
bm = bmesh.from_edit_mesh(obj.data)
|
||||||
bmesh.ops.dissolve_limit(bm, angle_limit=pi / 180 * 1, verts=bm.verts, edges=bm.edges)
|
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):
|
def execute(self, context):
|
||||||
selected_objs = context.selected_objects
|
selected_objs = context.selected_objects
|
||||||
|
for obj in selected_objs:
|
||||||
|
bpy.ops.bim.dynamically_void_product(obj=obj.name)
|
||||||
if len(selected_objs) == 0:
|
if len(selected_objs) == 0:
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
if not self.join_type:
|
if not self.join_type:
|
||||||
|
|||||||
Reference in New Issue
Block a user