mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-28 03:05:33 +00:00
Fix bug where a styled item could be incorrectly assigned if an element has more than one representation context
This commit is contained in:
@@ -1176,7 +1176,7 @@ class IfcParser:
|
|||||||
if not self.ifc_export_settings.has_representations:
|
if not self.ifc_export_settings.has_representations:
|
||||||
return results
|
return results
|
||||||
parsed_data_names = []
|
parsed_data_names = []
|
||||||
for product in self.selected_products + self.type_products:
|
for product in self.selected_products + self.selected_types:
|
||||||
obj = product["raw"]
|
obj = product["raw"]
|
||||||
if obj.data is None or obj.data.name in parsed_data_names:
|
if obj.data is None or obj.data.name in parsed_data_names:
|
||||||
continue
|
continue
|
||||||
@@ -1998,7 +1998,15 @@ class IfcExporter:
|
|||||||
]
|
]
|
||||||
material_slots = {}
|
material_slots = {}
|
||||||
if product["ifc"].Representation:
|
if product["ifc"].Representation:
|
||||||
|
# This is a simplification, which works since we are currently in a controlled environment where the
|
||||||
|
# BlenderBIM Add-on controls how data is structured during export. When we implement full IFC
|
||||||
|
# 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
|
||||||
|
# items only apply to the body context. This is therefore an incomplete implementation and may break
|
||||||
|
# in edge cases.
|
||||||
|
if representation.RepresentationIdentifier != "Body":
|
||||||
|
continue
|
||||||
for mapped_item in representation.Items:
|
for mapped_item in representation.Items:
|
||||||
items = mapped_item[0].MappedRepresentation.Items
|
items = mapped_item[0].MappedRepresentation.Items
|
||||||
for i, item in enumerate(items):
|
for i, item in enumerate(items):
|
||||||
|
|||||||
@@ -179,7 +179,6 @@ class MaterialCreator:
|
|||||||
self.create_new_single(material)
|
self.create_new_single(material)
|
||||||
self.obj.BIMObjectProperties.material_type = "IfcMaterial"
|
self.obj.BIMObjectProperties.material_type = "IfcMaterial"
|
||||||
self.obj.BIMObjectProperties.material = self.materials[material.Name]
|
self.obj.BIMObjectProperties.material = self.materials[material.Name]
|
||||||
return self.assign_material_to_mesh(self.materials[material.Name])
|
|
||||||
|
|
||||||
def create_layer_set(self, layer_set):
|
def create_layer_set(self, layer_set):
|
||||||
props = self.obj.BIMObjectProperties
|
props = self.obj.BIMObjectProperties
|
||||||
@@ -190,9 +189,7 @@ class MaterialCreator:
|
|||||||
new = props.material_set.material_layers.add()
|
new = props.material_set.material_layers.add()
|
||||||
if layer.Material:
|
if layer.Material:
|
||||||
if layer.Material.Name not in self.materials:
|
if layer.Material.Name not in self.materials:
|
||||||
# TODO import rest of the layer set data
|
|
||||||
self.create_new_single(layer.Material)
|
self.create_new_single(layer.Material)
|
||||||
self.assign_material_to_mesh(self.materials[layer.Material.Name])
|
|
||||||
new.material = self.materials[layer.Material.Name]
|
new.material = self.materials[layer.Material.Name]
|
||||||
new.layer_thickness = layer.LayerThickness
|
new.layer_thickness = layer.LayerThickness
|
||||||
new.is_ventilated = "TRUE" if layer.IsVentilated else "FALSE"
|
new.is_ventilated = "TRUE" if layer.IsVentilated else "FALSE"
|
||||||
@@ -214,9 +211,7 @@ class MaterialCreator:
|
|||||||
new.name = constituent.Name or ""
|
new.name = constituent.Name or ""
|
||||||
new.description = constituent.Description or ""
|
new.description = constituent.Description or ""
|
||||||
if constituent.Material.Name not in self.materials:
|
if constituent.Material.Name not in self.materials:
|
||||||
# TODO import rest of the layer set data
|
|
||||||
self.create_new_single(constituent.Material)
|
self.create_new_single(constituent.Material)
|
||||||
self.assign_material_to_mesh(self.materials[constituent.Material.Name])
|
|
||||||
new.material = self.materials[constituent.Material.Name]
|
new.material = self.materials[constituent.Material.Name]
|
||||||
new.fraction = constituent.Fraction or 0.0
|
new.fraction = constituent.Fraction or 0.0
|
||||||
new.category = constituent.Category or ""
|
new.category = constituent.Category or ""
|
||||||
@@ -231,9 +226,7 @@ class MaterialCreator:
|
|||||||
new.name = profile.Name or ""
|
new.name = profile.Name or ""
|
||||||
new.description = profile.Description or ""
|
new.description = profile.Description or ""
|
||||||
if profile.Material.Name not in self.materials:
|
if profile.Material.Name not in self.materials:
|
||||||
# TODO import rest of the layer set data
|
|
||||||
self.create_new_single(profile.Material)
|
self.create_new_single(profile.Material)
|
||||||
self.assign_material_to_mesh(self.materials[profile.Material.Name])
|
|
||||||
new.material = self.materials[profile.Material.Name]
|
new.material = self.materials[profile.Material.Name]
|
||||||
new.profile = profile.Profile.is_a()
|
new.profile = profile.Profile.is_a()
|
||||||
for i, attribute in enumerate(profile.Profile):
|
for i, attribute in enumerate(profile.Profile):
|
||||||
@@ -249,9 +242,7 @@ class MaterialCreator:
|
|||||||
for material in material_list.Materials:
|
for material in material_list.Materials:
|
||||||
new = props.material_set.material_constituents.add()
|
new = props.material_set.material_constituents.add()
|
||||||
if material.Name not in self.materials:
|
if material.Name not in self.materials:
|
||||||
# TODO import rest of the layer set data
|
|
||||||
self.create_new_single(material)
|
self.create_new_single(material)
|
||||||
self.assign_material_to_mesh(self.materials[material.Name])
|
|
||||||
new.material = self.materials[material.Name]
|
new.material = self.materials[material.Name]
|
||||||
|
|
||||||
def create_new_single(self, material):
|
def create_new_single(self, material):
|
||||||
|
|||||||
Reference in New Issue
Block a user