mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-12 06:32:09 +00:00
Fix bug where spatial elements didn't get styles exported correctly
This commit is contained in:
@@ -112,8 +112,8 @@ class IfcParser:
|
|||||||
self.constraints = self.get_constraints()
|
self.constraints = self.get_constraints()
|
||||||
self.load_representations()
|
self.load_representations()
|
||||||
self.load_presentation_layer_assignments()
|
self.load_presentation_layer_assignments()
|
||||||
|
# TODO: migrate this into the product / type / spatial element loop
|
||||||
self.get_materials_and_surface_styles()
|
self.get_materials_and_surface_styles()
|
||||||
self.get_styled_items_and_surface_styles()
|
|
||||||
self.spatial_structure_elements = self.get_spatial_structure_elements()
|
self.spatial_structure_elements = self.get_spatial_structure_elements()
|
||||||
self.groups = self.get_groups()
|
self.groups = self.get_groups()
|
||||||
self.libraries = self.get_libraries()
|
self.libraries = self.get_libraries()
|
||||||
@@ -420,6 +420,7 @@ class IfcParser:
|
|||||||
|
|
||||||
self.get_product_psets_qtos(product, obj, is_pset=True)
|
self.get_product_psets_qtos(product, obj, is_pset=True)
|
||||||
self.get_product_psets_qtos(product, obj, is_qto=True)
|
self.get_product_psets_qtos(product, obj, is_qto=True)
|
||||||
|
self.get_styled_items_and_surface_styles(product, obj)
|
||||||
|
|
||||||
for reference in obj.BIMObjectProperties.document_references:
|
for reference in obj.BIMObjectProperties.document_references:
|
||||||
self.rel_associates_document_object.setdefault(reference.name, []).append(product)
|
self.rel_associates_document_object.setdefault(reference.name, []).append(product)
|
||||||
@@ -958,6 +959,7 @@ class IfcParser:
|
|||||||
self.append_product_attributes(element, obj)
|
self.append_product_attributes(element, obj)
|
||||||
self.get_product_psets_qtos(element, obj, is_pset=True)
|
self.get_product_psets_qtos(element, obj, is_pset=True)
|
||||||
self.get_product_psets_qtos(element, obj, is_qto=True)
|
self.get_product_psets_qtos(element, obj, is_qto=True)
|
||||||
|
self.get_styled_items_and_surface_styles(element, obj)
|
||||||
elements.append(element)
|
elements.append(element)
|
||||||
return elements
|
return elements
|
||||||
|
|
||||||
@@ -1160,7 +1162,7 @@ class IfcParser:
|
|||||||
def get_materials_and_surface_styles(self):
|
def get_materials_and_surface_styles(self):
|
||||||
if not self.ifc_export_settings.has_representations:
|
if not self.ifc_export_settings.has_representations:
|
||||||
return
|
return
|
||||||
for product in self.selected_products + self.selected_types:
|
for product in self.selected_products + self.selected_types + self.selected_spatial_structure_elements:
|
||||||
obj = product["raw"]
|
obj = product["raw"]
|
||||||
if obj.BIMObjectProperties.material_type == "IfcMaterial" and obj.BIMObjectProperties.material:
|
if obj.BIMObjectProperties.material_type == "IfcMaterial" and obj.BIMObjectProperties.material:
|
||||||
self.get_material(obj.BIMObjectProperties.material)
|
self.get_material(obj.BIMObjectProperties.material)
|
||||||
@@ -1191,27 +1193,23 @@ class IfcParser:
|
|||||||
attributes.update({a.name: a.string_value for a in material.BIMMaterialProperties.attributes})
|
attributes.update({a.name: a.string_value for a in material.BIMMaterialProperties.attributes})
|
||||||
return attributes
|
return attributes
|
||||||
|
|
||||||
def get_styled_items_and_surface_styles(self):
|
def get_styled_items_and_surface_styles(self, element, obj):
|
||||||
if not self.ifc_export_settings.has_representations:
|
if not self.ifc_export_settings.has_representations:
|
||||||
return
|
return
|
||||||
parsed_data_names = []
|
if obj.data is None:
|
||||||
for product in self.selected_products + self.selected_types:
|
return
|
||||||
obj = product["raw"]
|
for slot in obj.material_slots:
|
||||||
if obj.data is None or obj.data.name in parsed_data_names:
|
if slot.material is None:
|
||||||
continue
|
continue
|
||||||
parsed_data_names.append(obj.data.name)
|
self.surface_styles[slot.material.name] = {"ifc": None, "raw": slot.material}
|
||||||
for slot in obj.material_slots:
|
self.styled_items.append(
|
||||||
if slot.material is None:
|
{
|
||||||
continue
|
"ifc": None,
|
||||||
self.surface_styles[slot.material.name] = {"ifc": None, "raw": slot.material}
|
"raw": slot.material,
|
||||||
self.styled_items.append(
|
"related_element": element,
|
||||||
{
|
"attributes": {"Name": slot.material.name},
|
||||||
"ifc": None,
|
}
|
||||||
"raw": slot.material,
|
)
|
||||||
"related_product_name": product["raw"].name,
|
|
||||||
"attributes": {"Name": slot.material.name},
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
def get_grid_axes(self):
|
def get_grid_axes(self):
|
||||||
results = {}
|
results = {}
|
||||||
@@ -2025,9 +2023,7 @@ class IfcExporter:
|
|||||||
self.process_styled_item(styled_item)
|
self.process_styled_item(styled_item)
|
||||||
|
|
||||||
def process_styled_item(self, styled_item):
|
def process_styled_item(self, styled_item):
|
||||||
product = self.ifc_parser.products[
|
product = styled_item["related_element"]
|
||||||
self.ifc_parser.get_product_index_from_raw_name(styled_item["related_product_name"])
|
|
||||||
]
|
|
||||||
|
|
||||||
if not product["ifc"].Representation:
|
if not product["ifc"].Representation:
|
||||||
return
|
return
|
||||||
@@ -2037,9 +2033,7 @@ class IfcExporter:
|
|||||||
# BlenderBIM Add-on controls how data is structured during export. When we implement full IFC
|
# BlenderBIM Add-on controls how data is structured during export. When we implement full IFC
|
||||||
# round-tripping, this simplification can no longer apply.
|
# round-tripping, this simplification can no longer apply.
|
||||||
for representation in product["ifc"].Representation.Representations:
|
for representation in product["ifc"].Representation.Representations:
|
||||||
# At the moment, until we implement full support for round-tripping contexts, we assume that styled
|
# At the moment, we assume that styled items only apply to the body context.
|
||||||
# items only apply to the body context. This is therefore an incomplete implementation and may break
|
|
||||||
# in edge cases.
|
|
||||||
if representation.RepresentationIdentifier != "Body":
|
if representation.RepresentationIdentifier != "Body":
|
||||||
continue
|
continue
|
||||||
rep_context = self.ifc_parser.get_obj_representation_context(product["raw"], "Model", "Body", "MODEL_VIEW")
|
rep_context = self.ifc_parser.get_obj_representation_context(product["raw"], "Model", "Body", "MODEL_VIEW")
|
||||||
|
|||||||
Reference in New Issue
Block a user