mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-19 22:50:21 +00:00
Fix ridiculous bug where util.element.get_container didn't consider all parents and therefore didn't correctly contain feature elements in the spatial hierarchy
This commit is contained in:
@@ -573,6 +573,7 @@ class AddElement(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
new.obj = obj
|
new.obj = obj
|
||||||
bpy.ops.bim.show_openings()
|
bpy.ops.bim.show_openings()
|
||||||
tool.Model.purge_scene_openings()
|
tool.Model.purge_scene_openings()
|
||||||
|
tool.Collector.assign(obj)
|
||||||
|
|
||||||
bonsai.core.geometry.edit_object_placement(tool.Ifc, tool.Geometry, tool.Surveyor, obj=obj)
|
bonsai.core.geometry.edit_object_placement(tool.Ifc, tool.Geometry, tool.Surveyor, obj=obj)
|
||||||
tool.Blender.set_active_object(obj)
|
tool.Blender.set_active_object(obj)
|
||||||
|
|||||||
@@ -62,10 +62,6 @@ class Collector(bonsai.core.tool.Collector):
|
|||||||
elif element.is_a("IfcTypeProduct"):
|
elif element.is_a("IfcTypeProduct"):
|
||||||
collection = cls._create_project_child_collection("IfcTypeProduct")
|
collection = cls._create_project_child_collection("IfcTypeProduct")
|
||||||
cls.link_collection_object_safe(collection, obj)
|
cls.link_collection_object_safe(collection, obj)
|
||||||
elif element.is_a("IfcOpeningElement"):
|
|
||||||
collection = cls._create_project_child_collection("IfcOpeningElement")
|
|
||||||
cls.link_collection_object_safe(collection, obj)
|
|
||||||
obj.display_type = "WIRE"
|
|
||||||
elif element.is_a("IfcSpace"):
|
elif element.is_a("IfcSpace"):
|
||||||
collection = cls._create_project_child_collection("IfcSpace")
|
collection = cls._create_project_child_collection("IfcSpace")
|
||||||
cls.link_collection_object_safe(collection, obj)
|
cls.link_collection_object_safe(collection, obj)
|
||||||
@@ -122,6 +118,9 @@ class Collector(bonsai.core.tool.Collector):
|
|||||||
collection = cls._create_project_child_collection("Unsorted")
|
collection = cls._create_project_child_collection("Unsorted")
|
||||||
cls.link_collection_object_safe(collection, obj)
|
cls.link_collection_object_safe(collection, obj)
|
||||||
|
|
||||||
|
if element.is_a("IfcFeatureElementSubtraction"):
|
||||||
|
obj.display_type = "WIRE"
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _create_project_child_collection(cls, name: str) -> bpy.types.Collection:
|
def _create_project_child_collection(cls, name: str) -> bpy.types.Collection:
|
||||||
"""get or create new collection inside project"""
|
"""get or create new collection inside project"""
|
||||||
|
|||||||
@@ -926,23 +926,16 @@ def get_container(
|
|||||||
return container
|
return container
|
||||||
if container.is_a(ifc_class):
|
if container.is_a(ifc_class):
|
||||||
return container
|
return container
|
||||||
else:
|
elif contained_in_structure := getattr(element, "ContainedInStructure", None):
|
||||||
aggregate = get_aggregate(element)
|
container = contained_in_structure[0].RelatingStructure
|
||||||
if aggregate:
|
if not ifc_class:
|
||||||
return get_container(aggregate, should_get_direct)
|
return container
|
||||||
nest = get_nest(element)
|
while container:
|
||||||
if nest:
|
if container.is_a(ifc_class):
|
||||||
return get_container(nest, should_get_direct)
|
|
||||||
if (
|
|
||||||
contained_in_structure := getattr(element, "ContainedInStructure", None)
|
|
||||||
) is not None and contained_in_structure:
|
|
||||||
container = contained_in_structure[0].RelatingStructure
|
|
||||||
if not ifc_class:
|
|
||||||
return container
|
return container
|
||||||
while container:
|
container = get_aggregate(container)
|
||||||
if container.is_a(ifc_class):
|
elif parent := get_parent(element):
|
||||||
return container
|
return get_container(parent, should_get_direct)
|
||||||
container = get_aggregate(container)
|
|
||||||
|
|
||||||
|
|
||||||
def get_referenced_structures(element: ifcopenshell.entity_instance) -> list[ifcopenshell.entity_instance]:
|
def get_referenced_structures(element: ifcopenshell.entity_instance) -> list[ifcopenshell.entity_instance]:
|
||||||
|
|||||||
Reference in New Issue
Block a user