Cleaned up meshes produced during slab / arbitrary profile edit

Previously it was producing orphan meshes
This commit is contained in:
Andrej730
2023-03-29 13:49:36 +05:00
parent eb35aad6e3
commit d19c7d27a8
3 changed files with 14 additions and 0 deletions
@@ -562,6 +562,7 @@ def disable_editing_extrusion_profile(context):
element = tool.Ifc.get_entity(obj)
body = ifcopenshell.util.representation.get_representation(element, "Model", "Body", "MODEL_VIEW")
profile_mesh = obj.data
blenderbim.core.geometry.switch_representation(
tool.Ifc,
tool.Geometry,
@@ -571,6 +572,7 @@ def disable_editing_extrusion_profile(context):
is_global=True,
should_sync_changes_first=False,
)
tool.Geometry.delete_data(profile_mesh)
return {"FINISHED"}
@@ -663,6 +665,7 @@ class EditExtrusionProfile(bpy.types.Operator, tool.Ifc.Operator):
ifcopenshell.util.element.replace_attribute(inverse, old_profile, profile)
ifcopenshell.util.element.remove_deep2(tool.Ifc.get(), old_profile)
profile_mesh = obj.data
blenderbim.core.geometry.switch_representation(
tool.Ifc,
tool.Geometry,
@@ -672,6 +675,7 @@ class EditExtrusionProfile(bpy.types.Operator, tool.Ifc.Operator):
is_global=True,
should_sync_changes_first=False,
)
bpy.data.meshes.remove(profile_mesh)
footprint_context = ifcopenshell.util.representation.get_context(
tool.Ifc.get(), "Plan", "FootPrint", "SKETCH_VIEW"
@@ -148,7 +148,9 @@ def disable_editing_arbitrary_profile(context):
if obj and obj.data and obj.data.BIMMeshProperties.subshape_type == "PROFILE":
ProfileDecorator.uninstall()
bpy.ops.object.mode_set(mode="OBJECT")
profile_mesh = obj.data
bpy.data.objects.remove(obj)
bpy.data.meshes.remove(profile_mesh)
# need to update profile manager ui
# if this was called from decorator
@@ -191,7 +193,10 @@ class EditArbitraryProfile(bpy.types.Operator, tool.Ifc.Operator):
bpy.ops.object.mode_set(mode="EDIT")
return
profile_mesh = obj.data
bpy.data.objects.remove(obj)
bpy.data.meshes.remove(profile_mesh)
profile.ProfileType = old_profile.ProfileType
profile.ProfileName = old_profile.ProfileName
for inverse in tool.Ifc.get().get_inverse(old_profile):
+5
View File
@@ -176,6 +176,11 @@ class Model(blenderbim.core.tool.Model):
@classmethod
def import_profile(cls, profile, obj=None, position=None):
"""Creates new profile mesh and assigns it to `obj`,
if `obj` is `None` then new "Profile" object will be created.
Need to make sure to remove temporary mesh/object after use to avoid orphan data.
"""
cls.unit_scale = ifcopenshell.util.unit.calculate_unit_scale(tool.Ifc.get())
if position is None: