I can do a LOT of things with Python in Blender, but for some reason I'm struggling with changing the material name.
When I import an FBX Blender renames the material names if they are dupes. So I get a "Glass.001", "Glass.002" but I really need them to all just be "Glass". I can rename them manually with no problems, but my code to do so fails.
for obj in bpy.data.objects:
for num, m in list(enumerate(obj.material_slots)): #rename materials with . numbers
if m.material:
myhold = m.material.name
if myhold.find(".") > -1:
print ("Material is", m.material.name)
tempholder = myhold[:myhold.find(".")]
m.material.name = tempholder
print ("Material is now", tempholder)
print ("So should be", m.material.name)
which prints something like:
"Material is Glass.001" "Material is now Glass" "So should be Glass.001"
It must be something obvious but I don't get it. TIA for any help.

