IFC Join - prevent joining rep items into non items

Because it was removing representation item object leaving Bonsai in confusing state, which may lead to errors later
This commit is contained in:
Andrej730
2025-04-28 16:22:29 +05:00
parent 5e16588eb7
commit 308d628b1e
@@ -1536,6 +1536,7 @@ class OverrideJoin(bpy.types.Operator, tool.Ifc.Operator):
blender_op.description
+ ".\nAlso makes sure changes are in sync with IFC."
+ "\nIf IFC object is joined into non-IFC object, it will be removed from IFC."
+ "\nJoining representation items only supported for joining with other representation items of the same representation."
)
bl_options = {"REGISTER", "UNDO"}
@@ -1627,6 +1628,8 @@ class OverrideJoin(bpy.types.Operator, tool.Ifc.Operator):
element = tool.Ifc.get_entity(obj)
if element:
ifcopenshell.api.root.remove_product(ifc_file, product=element)
elif tool.Geometry.is_representation_item(obj):
obj.select_set(False)
bpy.ops.object.join()
bpy.ops.bim.update_representation(obj=self.target.name, ifc_representation_class="")
else:
@@ -1656,6 +1659,7 @@ class OverrideJoin(bpy.types.Operator, tool.Ifc.Operator):
element = tool.Ifc.get_entity(obj)
# Non IFC elements cannot be joined since we cannot guarantee SweptSolid compliance
# This check also is also needed to skip representation items.
if not element:
obj.select_set(False)
continue
@@ -1772,6 +1776,8 @@ class OverrideJoin(bpy.types.Operator, tool.Ifc.Operator):
element = tool.Ifc.get_entity(obj)
if element:
ifcopenshell.api.root.remove_product(ifc_file, product=element)
elif tool.Geometry.is_representation_item(obj):
obj.select_set(False)
bpy.ops.object.join()