Switch representation now cleans up orphaned meshes itself so callers don't need that responsibility

This commit is contained in:
Dion Moult
2024-09-18 22:57:51 +10:00
parent 81e4ad2ce2
commit 1320eac800
4 changed files with 7 additions and 7 deletions
@@ -138,7 +138,6 @@ class DumbProfileGenerator:
is_global=True,
should_sync_changes_first=False,
)
tool.Blender.remove_data_block(mesh)
pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="EPset_Parametric")
ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"Engine": "Bonsai.DumbProfile"})
@@ -126,7 +126,6 @@ class DumbSlabGenerator:
is_global=True,
should_sync_changes_first=False,
)
tool.Blender.remove_data_block(mesh)
if self.footprint_context:
extrusion = tool.Model.get_extrusion(representation)
@@ -520,7 +519,6 @@ def disable_editing_extrusion_profile(context):
is_global=True,
should_sync_changes_first=False,
)
tool.Geometry.delete_data(profile_mesh)
return {"FINISHED"}
@@ -621,7 +619,6 @@ class EditExtrusionProfile(bpy.types.Operator, tool.Ifc.Operator):
is_global=True,
should_sync_changes_first=False,
)
bpy.data.meshes.remove(profile_mesh)
# Only certain classes should have a footprint
if element.is_a() not in ("IfcSlab", "IfcRamp"):
@@ -712,7 +712,6 @@ class DumbWallGenerator:
is_global=True,
should_sync_changes_first=False,
)
tool.Blender.remove_data_block(mesh)
pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="EPset_Parametric")
ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"Engine": "Bonsai.DumbLayer2"})
obj.select_set(True)
+7 -2
View File
@@ -662,9 +662,14 @@ class Geometry(bonsai.core.tool.Geometry):
settings.set("disable-opening-subtractions", True)
shape = None
iterator = ifcopenshell.geom.iterator(settings, tool.Ifc.get(), multiprocessing.cpu_count(), include=elements)
if elements:
iterator = ifcopenshell.geom.iterator(
settings, tool.Ifc.get(), multiprocessing.cpu_count(), include=elements
)
else:
iterator = None # For example, when switching representation of a type with no occurrences
meshes = {}
if iterator.initialize():
if iterator and iterator.initialize():
while True:
shape = iterator.get()
element = tool.Ifc.get().by_id(shape.id)