mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 17:31:45 +00:00
Remove spatial containment and aggregation when nesting
The nest assign_object API now removes existing spatial containment and aggregate relationships before creating the nest, matching the behavior documented in its docstring and consistent with aggregate.assign_object. Fix #7248 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -19,7 +19,9 @@
|
||||
from typing import Union
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api.aggregate
|
||||
import ifcopenshell.api.owner
|
||||
import ifcopenshell.api.spatial
|
||||
import ifcopenshell.guid
|
||||
import ifcopenshell.util.element
|
||||
|
||||
@@ -137,7 +139,10 @@ def assign_object(
|
||||
if not objects_to_change:
|
||||
return is_nested_by
|
||||
|
||||
# NOTE: An object can both be nested and assigned to a container or an aggregate.
|
||||
# Can be either only nested, aggregated, or contained at the same time.
|
||||
possibly_contained = [o for o in objects_without_nests if hasattr(o, "ContainedInStructure")]
|
||||
ifcopenshell.api.spatial.unassign_container(file, products=possibly_contained)
|
||||
ifcopenshell.api.aggregate.unassign_object(file, products=objects_without_nests)
|
||||
|
||||
# unassign elements from previous nests
|
||||
for nests in previous_nests_rels:
|
||||
|
||||
Reference in New Issue
Block a user