mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-11 06:18:09 +00:00
BBIM support importing IfcRelAdheresToElement #4565
This commit is contained in:
@@ -430,7 +430,7 @@ class IfcImporter:
|
|||||||
self.annotations = set([a for a in self.file.by_type("IfcAnnotation")])
|
self.annotations = set([a for a in self.file.by_type("IfcAnnotation")])
|
||||||
self.annotations -= drawing_annotations
|
self.annotations -= drawing_annotations
|
||||||
|
|
||||||
self.elements = [e for e in self.elements if not e.is_a("IfcFeatureElement")]
|
self.elements = [e for e in self.elements if not e.is_a("IfcFeatureElement") or e.is_a("IfcSurfaceFeature")]
|
||||||
if self.ifc_import_settings.is_coordinating:
|
if self.ifc_import_settings.is_coordinating:
|
||||||
self.elements = [e for e in self.elements if e.Representation]
|
self.elements = [e for e in self.elements if e.Representation]
|
||||||
|
|
||||||
@@ -859,7 +859,6 @@ class IfcImporter:
|
|||||||
else:
|
else:
|
||||||
self.create_generic_elements(self.spatial_elements, unselectable=False)
|
self.create_generic_elements(self.spatial_elements, unselectable=False)
|
||||||
|
|
||||||
|
|
||||||
def create_elements(self) -> None:
|
def create_elements(self) -> None:
|
||||||
self.create_generic_elements(self.elements)
|
self.create_generic_elements(self.elements)
|
||||||
tmp = self.context_settings
|
tmp = self.context_settings
|
||||||
@@ -1632,6 +1631,8 @@ class IfcImporter:
|
|||||||
rel_aggregates.add(nested_by[0])
|
rel_aggregates.add(nested_by[0])
|
||||||
elif nests := getattr(element, "Nests", []):
|
elif nests := getattr(element, "Nests", []):
|
||||||
rel_aggregates.add(nests[0])
|
rel_aggregates.add(nests[0])
|
||||||
|
elif element.is_a("IfcSurfaceFeature") and self.file.schema == "IFC4X3":
|
||||||
|
rel_aggregates.add(element.AdheresToElement[0])
|
||||||
else:
|
else:
|
||||||
rel_aggregates = [
|
rel_aggregates = [
|
||||||
r
|
r
|
||||||
@@ -1647,6 +1648,8 @@ class IfcImporter:
|
|||||||
)
|
)
|
||||||
and [e for e in r.RelatedObjects if not e.is_a("IfcPort")]
|
and [e for e in r.RelatedObjects if not e.is_a("IfcPort")]
|
||||||
]
|
]
|
||||||
|
if self.file.schema == "IFC4X3":
|
||||||
|
rel_aggregates += [r for r in self.file.by_type("IfcRelAdheresToElement")]
|
||||||
|
|
||||||
if len(rel_aggregates) > 10000:
|
if len(rel_aggregates) > 10000:
|
||||||
# More than 10,000 collections makes Blender unhappy
|
# More than 10,000 collections makes Blender unhappy
|
||||||
@@ -1656,7 +1659,9 @@ class IfcImporter:
|
|||||||
|
|
||||||
aggregates: dict[str, dict] = {}
|
aggregates: dict[str, dict] = {}
|
||||||
for rel_aggregate in rel_aggregates:
|
for rel_aggregate in rel_aggregates:
|
||||||
element: ifcopenshell.entity_instance = rel_aggregate.RelatingObject
|
element: ifcopenshell.entity_instance = getattr(rel_aggregate, "RelatingObject", None) or getattr(
|
||||||
|
rel_aggregate, "RelatingElement"
|
||||||
|
)
|
||||||
collection = bpy.data.collections.new(tool.Loader.get_name(element))
|
collection = bpy.data.collections.new(tool.Loader.get_name(element))
|
||||||
aggregates[element.GlobalId] = {"element": element, "collection": collection}
|
aggregates[element.GlobalId] = {"element": element, "collection": collection}
|
||||||
self.collections[element.GlobalId] = collection
|
self.collections[element.GlobalId] = collection
|
||||||
@@ -1757,6 +1762,9 @@ class IfcImporter:
|
|||||||
elif getattr(element, "Nests", None) and not element.is_a("IfcPort"):
|
elif getattr(element, "Nests", None) and not element.is_a("IfcPort"):
|
||||||
nest = ifcopenshell.util.element.get_nest(element)
|
nest = ifcopenshell.util.element.get_nest(element)
|
||||||
return self.collections[nest.GlobalId].objects.link(obj)
|
return self.collections[nest.GlobalId].objects.link(obj)
|
||||||
|
elif element.is_a("IfcSurfaceFeature") and self.file.schema == "IFC4X3":
|
||||||
|
adherend = element.AdheresToElement[0].RelatingElement
|
||||||
|
return self.collections[adherend.GlobalId].objects.link(obj)
|
||||||
|
|
||||||
return self.place_object_in_spatial_decomposition_collection(element, obj)
|
return self.place_object_in_spatial_decomposition_collection(element, obj)
|
||||||
|
|
||||||
|
|||||||
@@ -187,6 +187,9 @@ class Collector(blenderbim.core.tool.Collector):
|
|||||||
if any(e for e in element.IsNestedBy[0].RelatedObjects if not e.is_a("IfcPort")):
|
if any(e for e in element.IsNestedBy[0].RelatedObjects if not e.is_a("IfcPort")):
|
||||||
return cls._create_own_collection(obj)
|
return cls._create_own_collection(obj)
|
||||||
|
|
||||||
|
if getattr(element, "HasSurfaceFeatures", None):
|
||||||
|
return cls._create_own_collection(obj)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _get_collection(cls, element: ifcopenshell.entity_instance, obj: bpy.types.Object) -> bpy.types.Collection:
|
def _get_collection(cls, element: ifcopenshell.entity_instance, obj: bpy.types.Object) -> bpy.types.Collection:
|
||||||
"""get or create collection for the element based on it's type"""
|
"""get or create collection for the element based on it's type"""
|
||||||
@@ -247,6 +250,13 @@ class Collector(blenderbim.core.tool.Collector):
|
|||||||
if collection:
|
if collection:
|
||||||
return collection
|
return collection
|
||||||
|
|
||||||
|
if element.is_a("IfcSurfaceFeature") and element.file.schema == "IFC4X3":
|
||||||
|
adherend = element.AdheresToElement[0].RelatingElement
|
||||||
|
adherend_obj = tool.Ifc.get_object(adherend)
|
||||||
|
collection = adherend_obj.BIMObjectProperties.collection
|
||||||
|
if collection:
|
||||||
|
return collection
|
||||||
|
|
||||||
if element.is_a("IfcProject"):
|
if element.is_a("IfcProject"):
|
||||||
return bpy.context.scene.collection
|
return bpy.context.scene.collection
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user