From e7446dc6cbc7f418fc380f7d0fea36cb634b9db6 Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Thu, 30 Jul 2020 19:15:06 +1000 Subject: [PATCH] Fix bug #936 where long, duplicate, material names fail to import. --- src/ifcblenderexport/blenderbim/bim/import_ifc.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/ifcblenderexport/blenderbim/bim/import_ifc.py b/src/ifcblenderexport/blenderbim/bim/import_ifc.py index dd149bb1a2..96f8fb48e8 100644 --- a/src/ifcblenderexport/blenderbim/bim/import_ifc.py +++ b/src/ifcblenderexport/blenderbim/bim/import_ifc.py @@ -115,7 +115,13 @@ class MaterialCreator(): material = material.split('-')[2] if len(material) > 63: # Blender material names are up to 63 characters material = material[0:63] - material_to_slot[i] = slots.index(material) + try: + material_to_slot[i] = slots.index(material) + except: + # If the material name duplicates, a `.001` is added, this + # reduces the maxmium characters for the material name to 59. + material = material[0:59] + material_to_slot[i] = slots.index(material) if len(mesh.polygons) == len(mesh['ios_material_ids']): material_index = [(material_to_slot[mat_id] if mat_id != 999999