mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-11 22:31:55 +00:00
Deleting voided objects now works with new opening system
This commit is contained in:
@@ -90,47 +90,36 @@ class AddOpening(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
class RemoveOpening(bpy.types.Operator):
|
class RemoveOpening(bpy.types.Operator, tool.Ifc.Operator):
|
||||||
bl_idname = "bim.remove_opening"
|
bl_idname = "bim.remove_opening"
|
||||||
bl_label = "Remove Opening"
|
bl_label = "Remove Opening"
|
||||||
bl_options = {"REGISTER", "UNDO"}
|
bl_options = {"REGISTER", "UNDO"}
|
||||||
opening_id: bpy.props.IntProperty()
|
opening_id: bpy.props.IntProperty()
|
||||||
obj: bpy.props.StringProperty()
|
|
||||||
|
|
||||||
def execute(self, context):
|
|
||||||
return IfcStore.execute_ifc_operator(self, context)
|
|
||||||
|
|
||||||
def _execute(self, context):
|
def _execute(self, context):
|
||||||
obj = bpy.data.objects.get(self.obj) if self.obj else context.active_object
|
opening = tool.Ifc.get().by_id(self.opening_id)
|
||||||
self.file = IfcStore.get_file()
|
opening_obj = tool.Ifc.get_object(opening)
|
||||||
is_modifier_removed = False
|
element = opening.VoidsElements[0].RelatingBuildingElement
|
||||||
for modifier in obj.modifiers:
|
obj = tool.Ifc.get_object(element)
|
||||||
if modifier.type != "BOOLEAN":
|
|
||||||
continue
|
|
||||||
if modifier.object and modifier.object.BIMObjectProperties.ifc_definition_id == self.opening_id:
|
|
||||||
is_modifier_removed = True
|
|
||||||
obj.modifiers.remove(modifier)
|
|
||||||
break
|
|
||||||
|
|
||||||
opening = IfcStore.get_element(self.opening_id)
|
if opening_obj:
|
||||||
opening.name = "/".join(opening.name.split("/")[1:])
|
opening_obj.name = "/".join(opening_obj.name.split("/")[1:])
|
||||||
IfcStore.unlink_element(obj=opening)
|
IfcStore.unlink_element(obj=opening_obj)
|
||||||
|
|
||||||
ifcopenshell.api.run("void.remove_opening", self.file, **{"opening": self.file.by_id(self.opening_id)})
|
ifcopenshell.api.run("void.remove_opening", tool.Ifc.get(), opening=opening)
|
||||||
|
|
||||||
if not is_modifier_removed:
|
blenderbim.core.geometry.switch_representation(
|
||||||
blenderbim.core.geometry.switch_representation(
|
tool.Geometry,
|
||||||
tool.Geometry,
|
obj=obj,
|
||||||
obj=obj,
|
representation=tool.Ifc.get().by_id(obj.data.BIMMeshProperties.ifc_definition_id),
|
||||||
representation=tool.Ifc.get().by_id(obj.data.BIMMeshProperties.ifc_definition_id),
|
should_reload=True,
|
||||||
should_reload=True,
|
enable_dynamic_voids=False,
|
||||||
enable_dynamic_voids=False,
|
is_global=True,
|
||||||
is_global=True,
|
should_sync_changes_first=False,
|
||||||
should_sync_changes_first=False,
|
)
|
||||||
)
|
|
||||||
|
|
||||||
tool.Geometry.clear_cache(tool.Ifc.get_entity(obj))
|
tool.Geometry.clear_cache(element)
|
||||||
Data.load(IfcStore.get_file(), obj.BIMObjectProperties.ifc_definition_id)
|
Data.load(tool.Ifc.get(), obj.BIMObjectProperties.ifc_definition_id)
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -71,9 +71,7 @@ class BIM_PT_voids(Panel):
|
|||||||
else:
|
else:
|
||||||
obj_name = obj.name
|
obj_name = obj.name
|
||||||
if opening_id and obj_name:
|
if opening_id and obj_name:
|
||||||
op = row.operator("bim.remove_opening", icon="X", text="Remove Opening")
|
op = row.operator("bim.remove_opening", icon="X", text="Remove Opening").opening_id = opening_id
|
||||||
op.opening_id = opening_id
|
|
||||||
op.obj = obj_name
|
|
||||||
else:
|
else:
|
||||||
row.label(text="Select an opening and an element to modify", icon="HELP")
|
row.label(text="Select an opening and an element to modify", icon="HELP")
|
||||||
|
|
||||||
@@ -94,8 +92,7 @@ class BIM_PT_voids(Panel):
|
|||||||
else:
|
else:
|
||||||
row = self.layout.row(align=True)
|
row = self.layout.row(align=True)
|
||||||
row.label(text=opening["Name"], icon="SELECT_SUBTRACT")
|
row.label(text=opening["Name"], icon="SELECT_SUBTRACT")
|
||||||
op = row.operator("bim.remove_opening", icon="X", text="")
|
op = row.operator("bim.remove_opening", icon="X", text="").opening_id = opening_id
|
||||||
op.opening_id = opening_id
|
|
||||||
if props.ifc_definition_id in Data.openings:
|
if props.ifc_definition_id in Data.openings:
|
||||||
for filling_id in Data.openings[props.ifc_definition_id]["HasFillings"]:
|
for filling_id in Data.openings[props.ifc_definition_id]["HasFillings"]:
|
||||||
filling = Data.fillings.get(filling_id)
|
filling = Data.fillings.get(filling_id)
|
||||||
|
|||||||
Reference in New Issue
Block a user