mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-23 16:06:27 +00:00
Fix duplicate material assignment bug on import
This commit is contained in:
@@ -29,6 +29,9 @@ class MaterialCreator():
|
|||||||
self.mesh = mesh
|
self.mesh = mesh
|
||||||
if not element.Representation:
|
if not element.Representation:
|
||||||
return
|
return
|
||||||
|
if self.ifc_import_settings.should_treat_styled_item_as_material \
|
||||||
|
and self.mesh.name in self.parsed_meshes:
|
||||||
|
return
|
||||||
for item in element.Representation.Representations[0].Items:
|
for item in element.Representation.Representations[0].Items:
|
||||||
if item.is_a('IfcMappedItem'):
|
if item.is_a('IfcMappedItem'):
|
||||||
item = item.MappingSource.MappedRepresentation.Items[0]
|
item = item.MappingSource.MappedRepresentation.Items[0]
|
||||||
@@ -56,7 +59,6 @@ class MaterialCreator():
|
|||||||
# them as reusable materials makes things much more
|
# them as reusable materials makes things much more
|
||||||
# efficient in Blender.
|
# efficient in Blender.
|
||||||
if self.mesh.name not in self.parsed_meshes:
|
if self.mesh.name not in self.parsed_meshes:
|
||||||
self.parsed_meshes.append(self.mesh.name)
|
|
||||||
self.assign_material_to_mesh(self.materials[material_name])
|
self.assign_material_to_mesh(self.materials[material_name])
|
||||||
else:
|
else:
|
||||||
# Proper behaviour
|
# Proper behaviour
|
||||||
@@ -118,6 +120,7 @@ class MaterialCreator():
|
|||||||
material.BIMMaterialProperties.name = external_style.Name
|
material.BIMMaterialProperties.name = external_style.Name
|
||||||
|
|
||||||
def assign_material_to_mesh(self, material, is_styled_item=False):
|
def assign_material_to_mesh(self, material, is_styled_item=False):
|
||||||
|
self.parsed_meshes.append(self.mesh.name)
|
||||||
self.mesh.materials.append(material)
|
self.mesh.materials.append(material)
|
||||||
if is_styled_item:
|
if is_styled_item:
|
||||||
self.object.material_slots[0].link = 'OBJECT'
|
self.object.material_slots[0].link = 'OBJECT'
|
||||||
|
|||||||
Reference in New Issue
Block a user