mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-25 09:32:37 +00:00
Nesting collections only generate for element nesting, not port nesting
This commit is contained in:
@@ -640,7 +640,7 @@ class IfcImporter:
|
|||||||
if elements_checked > element_checking_threshold:
|
if elements_checked > element_checking_threshold:
|
||||||
return
|
return
|
||||||
if element.ObjectPlacement and element.ObjectPlacement.is_a("IfcLocalPlacement"):
|
if element.ObjectPlacement and element.ObjectPlacement.is_a("IfcLocalPlacement"):
|
||||||
placement = ifcopenshell.util.placement.get_local_placement(element.ObjectPlacement)[:,3][0:3]
|
placement = ifcopenshell.util.placement.get_local_placement(element.ObjectPlacement)[:, 3][0:3]
|
||||||
if self.is_point_far_away(placement, is_meters=False):
|
if self.is_point_far_away(placement, is_meters=False):
|
||||||
return placement
|
return placement
|
||||||
if not self.does_element_likely_have_geometry_far_away(element):
|
if not self.does_element_likely_have_geometry_far_away(element):
|
||||||
@@ -1550,20 +1550,27 @@ class IfcImporter:
|
|||||||
|
|
||||||
def create_aggregate_and_nest_collections(self):
|
def create_aggregate_and_nest_collections(self):
|
||||||
if self.ifc_import_settings.has_filter:
|
if self.ifc_import_settings.has_filter:
|
||||||
rel_aggregates = [e.IsDecomposedBy[0] for e in self.elements if e.IsDecomposedBy]
|
rel_aggregates = set()
|
||||||
rel_aggregates += [e.Decomposes[0] for e in self.elements if e.Decomposes]
|
for element in self.elements:
|
||||||
rel_aggregates += [e.IsNestedBy[0] for e in self.elements if e.IsNestedBy]
|
if element.IsDecomposedBy:
|
||||||
rel_aggregates += [e.Nests[0] for e in self.elements if e.Nests]
|
rel_aggregates.add(element.IsDecomposedBy[0])
|
||||||
rel_aggregates = set(rel_aggregates)
|
elif element.Decomposes:
|
||||||
|
rel_aggregates.add(element.Decomposes[0])
|
||||||
|
elif element.IsNestedBy:
|
||||||
|
if [e for e in element.IsNestedBy[0].RelatedObjects if not e.is_a("IfcPort")]:
|
||||||
|
rel_aggregates.add(element.IsNestedBy[0])
|
||||||
|
elif element.Nests:
|
||||||
|
rel_aggregates.add(element.Nests[0])
|
||||||
else:
|
else:
|
||||||
rel_aggregates = [
|
rel_aggregates = [
|
||||||
a
|
r
|
||||||
for a in self.file.by_type("IfcRelAggregates")
|
for r in self.file.by_type("IfcRelAggregates")
|
||||||
if a.RelatingObject.is_a("IfcElement") or a.RelatingObject.is_a("IfcElementType")
|
if r.RelatingObject.is_a("IfcElement") or r.RelatingObject.is_a("IfcElementType")
|
||||||
] + [
|
] + [
|
||||||
a
|
r
|
||||||
for a in self.file.by_type("IfcRelNests")
|
for r in self.file.by_type("IfcRelNests")
|
||||||
if a.RelatingObject.is_a("IfcElement") or a.RelatingObject.is_a("IfcElementType")
|
if (r.RelatingObject.is_a("IfcElement") or r.RelatingObject.is_a("IfcElementType"))
|
||||||
|
and [e for e in r.RelatedObjects if not e.is_a("IfcPort")]
|
||||||
]
|
]
|
||||||
|
|
||||||
if len(rel_aggregates) > 10000:
|
if len(rel_aggregates) > 10000:
|
||||||
|
|||||||
@@ -157,7 +157,8 @@ class Collector(blenderbim.core.tool.Collector):
|
|||||||
return cls._create_own_collection(obj)
|
return cls._create_own_collection(obj)
|
||||||
|
|
||||||
if getattr(element, "IsNestedBy", None):
|
if getattr(element, "IsNestedBy", None):
|
||||||
return cls._create_own_collection(obj)
|
if [e for e in element.IsNestedBy[0].RelatedObjects if not e.is_a("IfcPort")]:
|
||||||
|
return cls._create_own_collection(obj)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _get_collection(cls, element, obj):
|
def _get_collection(cls, element, obj):
|
||||||
|
|||||||
@@ -865,12 +865,16 @@ def get_parts(element):
|
|||||||
return element.IsDecomposedBy[0].RelatedObjects
|
return element.IsDecomposedBy[0].RelatedObjects
|
||||||
|
|
||||||
|
|
||||||
def get_components(element):
|
def get_components(element, include_ports=False):
|
||||||
"""
|
"""
|
||||||
Retrieves the components of an element that have an nest relationship.
|
Retrieves the components of an element that have an nest relationship.
|
||||||
|
|
||||||
|
For nested ports, see ifcopenshell.util.system.
|
||||||
|
|
||||||
:param element: The IFC element
|
:param element: The IFC element
|
||||||
:return: The components of the element
|
:return: The components of the element
|
||||||
|
:param include_ports: Default as False. Set to true if you also want to get ports.
|
||||||
|
:type include_ports: bool,optional
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
@@ -881,7 +885,9 @@ def get_components(element):
|
|||||||
"""
|
"""
|
||||||
if hasattr(element, "IsNestedBy"):
|
if hasattr(element, "IsNestedBy"):
|
||||||
if element.IsNestedBy:
|
if element.IsNestedBy:
|
||||||
return element.IsNestedBy[0].RelatedObjects
|
if include_ports:
|
||||||
|
return element.IsNestedBy[0].RelatedObjects
|
||||||
|
return [e for e in element.IsNestedBy[0].RelatedObjects if not e.is_a("IfcPort")]
|
||||||
elif hasattr(element, "IsDecomposedBy") and element.IsDecomposedBy:
|
elif hasattr(element, "IsDecomposedBy") and element.IsDecomposedBy:
|
||||||
if element.IsDecomposedBy[0].is_a("IfcRelNests"):
|
if element.IsDecomposedBy[0].is_a("IfcRelNests"):
|
||||||
return element.IsDecomposedBy[0].RelatedObjects
|
return element.IsDecomposedBy[0].RelatedObjects
|
||||||
|
|||||||
Reference in New Issue
Block a user