mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 17:58:20 +00:00
Fix bug where imported materials that duplicated a name could be incorrectly assigned
This commit is contained in:
@@ -5,6 +5,7 @@ import ifcopenshell.util.selector
|
||||
import bpy
|
||||
import bmesh
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
import threading
|
||||
import json
|
||||
@@ -105,7 +106,7 @@ class MaterialCreator():
|
||||
return
|
||||
if len(obj.material_slots) == 1:
|
||||
return
|
||||
slots = [s.name for s in obj.material_slots]
|
||||
slots = [self.canonicalise_material_name(s.name) for s in obj.material_slots]
|
||||
material_to_slot = {}
|
||||
for i, material in enumerate(mesh['ios_materials']):
|
||||
if material == 'NULLMAT':
|
||||
@@ -119,6 +120,9 @@ class MaterialCreator():
|
||||
else 0) for mat_id in mesh['ios_material_ids']]
|
||||
mesh.polygons.foreach_set('material_index', material_index)
|
||||
|
||||
def canonicalise_material_name(self, name):
|
||||
return re.sub(r'\.[0-9]{3}', '', name)
|
||||
|
||||
def parse_material(self, element):
|
||||
for association in element.HasAssociations:
|
||||
if association.is_a('IfcRelAssociatesMaterial'):
|
||||
|
||||
Reference in New Issue
Block a user