mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-12 02:23:34 +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:
|
||||
return results
|
||||
parsed_data_names = []
|
||||
for product in self.selected_products + self.type_products:
|
||||
for product in self.selected_products + self.selected_types:
|
||||
obj = product["raw"]
|
||||
if obj.data is None or obj.data.name in parsed_data_names:
|
||||
continue
|
||||
@@ -1998,7 +1998,15 @@ class IfcExporter:
|
||||
]
|
||||
material_slots = {}
|
||||
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:
|
||||
# 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:
|
||||
items = mapped_item[0].MappedRepresentation.Items
|
||||
for i, item in enumerate(items):
|
||||
|
||||
@@ -179,7 +179,6 @@ class MaterialCreator:
|
||||
self.create_new_single(material)
|
||||
self.obj.BIMObjectProperties.material_type = "IfcMaterial"
|
||||
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):
|
||||
props = self.obj.BIMObjectProperties
|
||||
@@ -190,9 +189,7 @@ class MaterialCreator:
|
||||
new = props.material_set.material_layers.add()
|
||||
if layer.Material:
|
||||
if layer.Material.Name not in self.materials:
|
||||
# TODO import rest of the layer set data
|
||||
self.create_new_single(layer.Material)
|
||||
self.assign_material_to_mesh(self.materials[layer.Material.Name])
|
||||
new.material = self.materials[layer.Material.Name]
|
||||
new.layer_thickness = layer.LayerThickness
|
||||
new.is_ventilated = "TRUE" if layer.IsVentilated else "FALSE"
|
||||
@@ -214,9 +211,7 @@ class MaterialCreator:
|
||||
new.name = constituent.Name or ""
|
||||
new.description = constituent.Description or ""
|
||||
if constituent.Material.Name not in self.materials:
|
||||
# TODO import rest of the layer set data
|
||||
self.create_new_single(constituent.Material)
|
||||
self.assign_material_to_mesh(self.materials[constituent.Material.Name])
|
||||
new.material = self.materials[constituent.Material.Name]
|
||||
new.fraction = constituent.Fraction or 0.0
|
||||
new.category = constituent.Category or ""
|
||||
@@ -231,9 +226,7 @@ class MaterialCreator:
|
||||
new.name = profile.Name or ""
|
||||
new.description = profile.Description or ""
|
||||
if profile.Material.Name not in self.materials:
|
||||
# TODO import rest of the layer set data
|
||||
self.create_new_single(profile.Material)
|
||||
self.assign_material_to_mesh(self.materials[profile.Material.Name])
|
||||
new.material = self.materials[profile.Material.Name]
|
||||
new.profile = profile.Profile.is_a()
|
||||
for i, attribute in enumerate(profile.Profile):
|
||||
@@ -249,9 +242,7 @@ class MaterialCreator:
|
||||
for material in material_list.Materials:
|
||||
new = props.material_set.material_constituents.add()
|
||||
if material.Name not in self.materials:
|
||||
# TODO import rest of the layer set data
|
||||
self.create_new_single(material)
|
||||
self.assign_material_to_mesh(self.materials[material.Name])
|
||||
new.material = self.materials[material.Name]
|
||||
|
||||
def create_new_single(self, material):
|
||||
|
||||
Reference in New Issue
Block a user