mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-17 14:02:27 +00:00
import IfcDistributionPorts with assets when executing append_library_element and for type products, use the type product's collection, not the container
This commit is contained in:
@@ -218,11 +218,22 @@ class System(bonsai.core.tool.System):
|
|||||||
ifc_importer.process_context_filter()
|
ifc_importer.process_context_filter()
|
||||||
ifc_importer.create_generic_elements(set(ports_to_create))
|
ifc_importer.create_generic_elements(set(ports_to_create))
|
||||||
|
|
||||||
container = ifcopenshell.util.element.get_container(element)
|
if element.is_a("IfcTypeProduct"):
|
||||||
if container:
|
target_collection = None
|
||||||
collection = tool.Blender.get_object_bim_props(tool.Ifc.get_object(container)).collection
|
for collection in obj.users_collection:
|
||||||
ifc_importer.collections[container.GlobalId] = collection
|
target_collection = collection
|
||||||
ifc_importer.place_objects_in_collections()
|
break
|
||||||
|
|
||||||
|
if target_collection:
|
||||||
|
for port_obj in ifc_importer.added_data.values():
|
||||||
|
if isinstance(port_obj, bpy.types.Object):
|
||||||
|
tool.Collector.link_collection_object_safe(target_collection, port_obj)
|
||||||
|
else:
|
||||||
|
container = ifcopenshell.util.element.get_container(element)
|
||||||
|
if container:
|
||||||
|
collection = tool.Blender.get_object_bim_props(tool.Ifc.get_object(container)).collection
|
||||||
|
ifc_importer.collections[container.GlobalId] = collection
|
||||||
|
ifc_importer.place_objects_in_collections()
|
||||||
|
|
||||||
for port_obj in ifc_importer.added_data.values():
|
for port_obj in ifc_importer.added_data.values():
|
||||||
assert isinstance(port_obj, bpy.types.Object)
|
assert isinstance(port_obj, bpy.types.Object)
|
||||||
|
|||||||
@@ -381,6 +381,7 @@ class Usecase:
|
|||||||
def append_type_product(self):
|
def append_type_product(self):
|
||||||
self.whitelisted_inverse_attributes = {
|
self.whitelisted_inverse_attributes = {
|
||||||
"IfcObjectDefinition": ["HasAssociations"],
|
"IfcObjectDefinition": ["HasAssociations"],
|
||||||
|
"IfcDistributionElementType": ["IsNestedBy"],
|
||||||
self.base_material_class: ["HasExternalReferences", "HasProperties", "HasRepresentation"],
|
self.base_material_class: ["HasExternalReferences", "HasProperties", "HasRepresentation"],
|
||||||
"IfcRepresentationItem": ["StyledByItem", "LayerAssignment"],
|
"IfcRepresentationItem": ["StyledByItem", "LayerAssignment"],
|
||||||
"IfcRepresentation": ["LayerAssignments"],
|
"IfcRepresentation": ["LayerAssignments"],
|
||||||
@@ -397,6 +398,7 @@ class Usecase:
|
|||||||
"IfcObjectDefinition": ["HasAssociations"],
|
"IfcObjectDefinition": ["HasAssociations"],
|
||||||
"IfcObject": ["IsDefinedBy.IfcRelDefinesByProperties"],
|
"IfcObject": ["IsDefinedBy.IfcRelDefinesByProperties"],
|
||||||
"IfcElement": ["HasOpenings"],
|
"IfcElement": ["HasOpenings"],
|
||||||
|
"IfcDistributionElement": ["IsNestedBy"],
|
||||||
self.base_material_class: ["HasExternalReferences", "HasProperties", "HasRepresentation"],
|
self.base_material_class: ["HasExternalReferences", "HasProperties", "HasRepresentation"],
|
||||||
"IfcRepresentationItem": [
|
"IfcRepresentationItem": [
|
||||||
"StyledByItem",
|
"StyledByItem",
|
||||||
@@ -488,7 +490,8 @@ class Usecase:
|
|||||||
attribute_class = None
|
attribute_class = None
|
||||||
if "." in attribute:
|
if "." in attribute:
|
||||||
attribute, attribute_class = attribute.split(".")
|
attribute, attribute_class = attribute.split(".")
|
||||||
for inverse in getattr(element, attribute, []):
|
inverse_values = getattr(element, attribute, [])
|
||||||
|
for inverse in inverse_values:
|
||||||
if attribute_class and inverse.is_a(attribute_class):
|
if attribute_class and inverse.is_a(attribute_class):
|
||||||
self.add_inverse_element(inverse)
|
self.add_inverse_element(inverse)
|
||||||
elif not attribute_class:
|
elif not attribute_class:
|
||||||
@@ -569,6 +572,8 @@ class Usecase:
|
|||||||
return False
|
return False
|
||||||
elif element.is_a("IfcRoot") and self.by_guid(element.GlobalId) is not None:
|
elif element.is_a("IfcRoot") and self.by_guid(element.GlobalId) is not None:
|
||||||
return False
|
return False
|
||||||
|
elif element.is_a("IfcDistributionPort"):
|
||||||
|
return False
|
||||||
elif element.is_a(self.target_class):
|
elif element.is_a(self.target_class):
|
||||||
return True
|
return True
|
||||||
elif self.target_class == "IfcProduct" and element.is_a("IfcTypeProduct"):
|
elif self.target_class == "IfcProduct" and element.is_a("IfcTypeProduct"):
|
||||||
|
|||||||
Reference in New Issue
Block a user