mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 17:31:45 +00:00
See #3974. WIP review to ensure history removal in API.
This commit is contained in:
@@ -111,6 +111,7 @@ class Usecase:
|
||||
self.change_profile(element)
|
||||
|
||||
if old_profile and len(self.file.get_inverse(old_profile)) == 0:
|
||||
# TODO: check remove deep
|
||||
self.file.remove(old_profile)
|
||||
|
||||
def change_profile(self, element):
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
class Usecase:
|
||||
@@ -59,7 +60,10 @@ class Usecase:
|
||||
elif inverse.is_a("IfcMaterialProfile"):
|
||||
self.file.remove(inverse)
|
||||
elif inverse.is_a("IfcRelAssociatesMaterial"):
|
||||
history = inverse.OwnerHistory
|
||||
self.file.remove(inverse)
|
||||
if history:
|
||||
ifcopenshell.util.element.remove_deep2(self.file, history)
|
||||
elif inverse.is_a("IfcMaterialProperties"):
|
||||
for prop in inverse.Properties or []:
|
||||
self.file.remove(prop)
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
class Usecase:
|
||||
@@ -73,7 +74,10 @@ class Usecase:
|
||||
self.file.remove(self.settings["material"])
|
||||
for inverse in inverse_elements:
|
||||
if inverse.is_a("IfcRelAssociatesMaterial"):
|
||||
history = inverse.OwnerHistory
|
||||
self.file.remove(inverse)
|
||||
if history:
|
||||
ifcopenshell.util.element.remove_deep2(self.file, history)
|
||||
elif inverse.is_a("IfcMaterialProperties"):
|
||||
for prop in inverse.Properties or []:
|
||||
self.file.remove(prop)
|
||||
|
||||
@@ -17,6 +17,10 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
class Usecase:
|
||||
def __init__(self, file, profile=None):
|
||||
"""Removes a profile item from a profile set
|
||||
@@ -65,5 +69,10 @@ class Usecase:
|
||||
self.settings = {"profile": profile}
|
||||
|
||||
def execute(self):
|
||||
subelements = set()
|
||||
for attribute in self.settings["profile"]:
|
||||
if isinstance(attribute, ifcopenshell.entity_instance):
|
||||
subelements.add(attribute)
|
||||
self.file.remove(self.settings["profile"])
|
||||
# TODO: deep purge
|
||||
for subelement in subelements:
|
||||
ifcopenshell.util.element.remove_deep2(self.file, subelement)
|
||||
|
||||
@@ -65,7 +65,10 @@ class Usecase:
|
||||
continue
|
||||
for inverse2 in self.file.get_inverse(inverse):
|
||||
if inverse2.is_a("IfcRelAssociatesMaterial"):
|
||||
history = inverse2.OwnerHistory
|
||||
self.file.remove(inverse2)
|
||||
if history:
|
||||
ifcopenshell.util.element.remove_deep2(self.file, history)
|
||||
else:
|
||||
if not inverse.is_a("IfcMaterialUsageDefinition"):
|
||||
continue
|
||||
@@ -80,7 +83,10 @@ class Usecase:
|
||||
if self.file.get_total_inverses(rel.RelatingMaterial) == 1 and len(rel.RelatedObjects) == 1:
|
||||
self.file.remove(rel.RelatingMaterial)
|
||||
if len(rel.RelatedObjects) == 1:
|
||||
history = rel.OwnerHistory
|
||||
self.file.remove(rel)
|
||||
if history:
|
||||
ifcopenshell.util.element.remove_deep2(self.file, history)
|
||||
continue
|
||||
related_objects = set(rel.RelatedObjects)
|
||||
related_objects.remove(self.settings["product"])
|
||||
|
||||
Reference in New Issue
Block a user