mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 17:58:20 +00:00
Changing aggregation now ensures spatial containment is mutually exclusive to prevent invalid IFC data
This commit is contained in:
@@ -26,6 +26,10 @@ class Usecase:
|
||||
if decomposes and decomposes == is_decomposed_by:
|
||||
return
|
||||
|
||||
container = ifcopenshell.util.element.get_container(self.settings["product"], should_get_direct=True)
|
||||
if container:
|
||||
ifcopenshell.api.run("spatial.remove_container", self.file, product=self.settings["product"])
|
||||
|
||||
if decomposes:
|
||||
related_objects = list(decomposes.RelatedObjects)
|
||||
related_objects.remove(self.settings["product"])
|
||||
@@ -50,4 +54,15 @@ class Usecase:
|
||||
"RelatingObject": self.settings["relating_object"],
|
||||
}
|
||||
)
|
||||
|
||||
placement = getattr(self.settings["product"], "ObjectPlacement", None)
|
||||
if placement and placement.is_a("IfcLocalPlacement"):
|
||||
ifcopenshell.api.run(
|
||||
"geometry.edit_object_placement",
|
||||
self.file,
|
||||
product=self.settings["product"],
|
||||
matrix=ifcopenshell.util.placement.get_local_placement(self.settings["product"].ObjectPlacement),
|
||||
is_si=False,
|
||||
)
|
||||
|
||||
return is_decomposed_by
|
||||
|
||||
@@ -60,3 +60,5 @@ class Usecase:
|
||||
matrix=ifcopenshell.util.placement.get_local_placement(self.settings["product"].ObjectPlacement),
|
||||
is_si=False,
|
||||
)
|
||||
|
||||
return contains_elements
|
||||
|
||||
@@ -78,12 +78,16 @@ def get_material(element, should_skip_usage=False):
|
||||
return get_material(relating_type, should_skip_usage)
|
||||
|
||||
|
||||
def get_container(element):
|
||||
aggregate = get_aggregate(element)
|
||||
if aggregate:
|
||||
return get_container(aggregate)
|
||||
if hasattr(element, "ContainedInStructure") and element.ContainedInStructure:
|
||||
return element.ContainedInStructure[0].RelatingStructure
|
||||
def get_container(element, should_get_direct=False):
|
||||
if should_get_direct:
|
||||
if hasattr(element, "ContainedInStructure") and element.ContainedInStructure:
|
||||
return element.ContainedInStructure[0].RelatingStructure
|
||||
else:
|
||||
aggregate = get_aggregate(element)
|
||||
if aggregate:
|
||||
return get_container(aggregate, should_get_direct)
|
||||
if hasattr(element, "ContainedInStructure") and element.ContainedInStructure:
|
||||
return element.ContainedInStructure[0].RelatingStructure
|
||||
|
||||
|
||||
def get_decomposition(element):
|
||||
|
||||
Reference in New Issue
Block a user