mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-20 06:58:56 +00:00
Allow objects to be an arbitrary collection as long as some parent is part of the spatial tree
This commit is contained in:
@@ -77,18 +77,30 @@ class IfcParser():
|
|||||||
'attributes': self.get_object_attributes(object)
|
'attributes': self.get_object_attributes(object)
|
||||||
}
|
}
|
||||||
product.update(attribute_override)
|
product.update(attribute_override)
|
||||||
for collection in object.users_collection:
|
for collection in product['raw'].users_collection:
|
||||||
if self.is_a_spatial_structure_element(self.get_ifc_class(collection.name)):
|
self.parse_product_spatial_structure(product, index, collection)
|
||||||
reference = self.get_spatial_structure_element_reference(collection.name)
|
|
||||||
self.rel_contained_in_spatial_structure.setdefault(reference, []).append(index)
|
|
||||||
product['relating_structure'] = reference
|
|
||||||
self.collection_name_filter.append(collection.name)
|
|
||||||
if object.parent \
|
if object.parent \
|
||||||
and self.is_a_type(self.get_ifc_class(object.parent.name)):
|
and self.is_a_type(self.get_ifc_class(object.parent.name)):
|
||||||
reference = self.get_type_product_reference(object.parent.name)
|
reference = self.get_type_product_reference(object.parent.name)
|
||||||
self.rel_defines_by_type.setdefault(reference, []).append(index)
|
self.rel_defines_by_type.setdefault(reference, []).append(index)
|
||||||
return product
|
return product
|
||||||
|
|
||||||
|
def parse_product_spatial_structure(self, product, index, collection):
|
||||||
|
if self.is_a_spatial_structure_element(self.get_ifc_class(collection.name)):
|
||||||
|
reference = self.get_spatial_structure_element_reference(collection.name)
|
||||||
|
self.rel_contained_in_spatial_structure.setdefault(reference, []).append(index)
|
||||||
|
product['relating_structure'] = reference
|
||||||
|
self.collection_name_filter.append(collection.name)
|
||||||
|
else:
|
||||||
|
self.parse_product_spatial_structure(product, index, self.get_parent_collection(collection))
|
||||||
|
|
||||||
|
def get_parent_collection(self, child_collection):
|
||||||
|
for parent_collection in bpy.data.collections:
|
||||||
|
for child in parent_collection.children:
|
||||||
|
if child.name == child_collection.name:
|
||||||
|
return parent_collection
|
||||||
|
|
||||||
def get_instances(self, object):
|
def get_instances(self, object):
|
||||||
instances = []
|
instances = []
|
||||||
for m in object.modifiers:
|
for m in object.modifiers:
|
||||||
|
|||||||
Reference in New Issue
Block a user