resource.remove_resource - fix issue removing resources in ifc2x3

This commit is contained in:
Andrej730
2024-06-03 12:37:56 +05:00
parent c399eb259a
commit 5fb7e6e375
2 changed files with 22 additions and 2 deletions
@@ -74,8 +74,9 @@ def remove_resource(file: ifcopenshell.file, resource: ifcopenshell.entity_insta
file.remove(inverse)
if history:
ifcopenshell.util.element.remove_deep2(file, history)
if settings["resource"].Usage:
file.remove(settings["resource"].Usage)
# Usage was added in IFC4.
if usage := getattr(settings["resource"], "Usage", None):
file.remove(usage)
if settings["resource"].BaseQuantity:
ifcopenshell.api.run(
"resource.remove_resource_quantity",
@@ -0,0 +1,19 @@
# IfcOpenShell - IFC toolkit and geometry engine
# Copyright (C) 2024 Dion Moult <dion@thinkmoult.com>
#
# This file is part of IfcOpenShell.
#
# IfcOpenShell is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# IfcOpenShell is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
# remove_resource tests is partially covered by test_add_resource_quantity.