mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-19 14:41:25 +00:00
bim.bulk_remove_psets - show how many psets were removed
Also removed exception handling to catch that bug sneaking in, if it ever returns.
This commit is contained in:
@@ -449,25 +449,27 @@ class BIM_OT_bulk_remove_psets(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
self.file = tool.Ifc.get()
|
self.file = tool.Ifc.get()
|
||||||
props = tool.Pset.get_global_pset_props()
|
props = tool.Pset.get_global_pset_props()
|
||||||
|
|
||||||
|
pset_names_to_delete = {p.name for p in props.psets_to_delete}
|
||||||
|
psets_removed = 0
|
||||||
|
|
||||||
for obj in tool.Blender.get_selected_objects():
|
for obj in tool.Blender.get_selected_objects():
|
||||||
ifc_element = tool.Ifc.get_entity(obj)
|
ifc_element = tool.Ifc.get_entity(obj)
|
||||||
if not ifc_element:
|
if not ifc_element:
|
||||||
continue
|
continue
|
||||||
psets = ifcopenshell.util.element.get_psets(ifc_element)
|
psets = ifcopenshell.util.element.get_psets(ifc_element)
|
||||||
|
|
||||||
for prop in props.psets_to_delete:
|
for pset_name, pset_data in psets.items():
|
||||||
pset = prop.name
|
if pset_name not in pset_names_to_delete:
|
||||||
if pset in psets:
|
continue
|
||||||
try:
|
|
||||||
ifcopenshell.api.pset.remove_pset(
|
|
||||||
self.file,
|
|
||||||
product=ifc_element,
|
|
||||||
pset=self.file.by_id(psets[pset]["id"]),
|
|
||||||
)
|
|
||||||
except KeyError:
|
|
||||||
pass # Sometimes the pset id is not found, I'm not sure why this happens though. - vulevukusej
|
|
||||||
|
|
||||||
self.report({"INFO"}, "Finished applying changes")
|
ifcopenshell.api.pset.remove_pset(
|
||||||
|
self.file,
|
||||||
|
product=ifc_element,
|
||||||
|
pset=self.file.by_id(pset_data["id"]),
|
||||||
|
)
|
||||||
|
psets_removed += 1
|
||||||
|
|
||||||
|
self.report({"INFO"}, f"Finished applying changes, {psets_removed} psets removed.")
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user