mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-11 18:16:40 +00:00
Fix bug where removing material set items weren't consistent in how they purged materials and profiles
Previously remove_profile would purge unused materials and profiles, but remove_layer and remove_constituent wouldn't. This was as subtle inconsitency. Now everything by default consistently retains materials and profiles, and has options to change this default.
This commit is contained in:
@@ -18,16 +18,16 @@
|
||||
import ifcopenshell
|
||||
|
||||
|
||||
def remove_constituent(file: ifcopenshell.file, constituent: ifcopenshell.entity_instance) -> None:
|
||||
def remove_constituent(
|
||||
file: ifcopenshell.file, constituent: ifcopenshell.entity_instance, should_remove_material: bool = False
|
||||
) -> None:
|
||||
"""Removes a constituent from a constituent set
|
||||
|
||||
Note that it is invalid to have zero items in a set, so you should leave
|
||||
at least one constituent to ensure a valid IFC dataset.
|
||||
|
||||
:param constituent: The IfcMaterialConstituent entity you want to remove
|
||||
:type constituent: ifcopenshell.entity_instance
|
||||
:return: None
|
||||
:rtype: None
|
||||
:param should_remove_material: If true, materials with no users will be removed
|
||||
|
||||
Example:
|
||||
|
||||
@@ -51,6 +51,7 @@ def remove_constituent(file: ifcopenshell.file, constituent: ifcopenshell.entity
|
||||
# invalid.
|
||||
ifcopenshell.api.material.remove_constituent(model, constituent=glazing)
|
||||
"""
|
||||
settings = {"constituent": constituent}
|
||||
|
||||
file.remove(settings["constituent"])
|
||||
material = layer.Material
|
||||
file.remove(constituent)
|
||||
if material and should_remove_material:
|
||||
ifcopenshell.util.element.remove_deep2(file, subelement)
|
||||
|
||||
Reference in New Issue
Block a user