Remove duplicate mat with same name and diff index

(RickyBlender) #1

got this little script

import bpy

mats = bpy.data.materials

for obj in bpy.context.selected_objects:

for slt in obj.material_slots:
    part = slt.name.rpartition('.')
    if part[2].isnumeric() and part[0] in mats:
        slt.material = mats.get(part[0])

but does not seem to work
I still have mat with same name but different index

anyone has a working simple addon for the selected object ?

thanks
happy bl

0 Likes

(RickyBlender) #2

I have an object with many duplicate name
so I need to remove the duplicate but also re assign the faces to one material

see image here


thanks
happy bl

0 Likes

(RickyBlender) #3

it looks like there must be a base name with no extension!

and also after script run
the object may end up with same mat name in several slot
so need something to eliminate these multi name !

any help appreciated
thanks
happy by

0 Likes

(<== Lost? Click Me) #4

Hi, maybe this gives an idea:

0 Likes

(RickyBlender) #5

will test that

one thing I don’t understand
after doing the other script
the object still has several material with same name
and different verts

how come there are several material slot with same name
but different verts assigned ?

I thought material list was a unique list
looks to me it is not or is it a bug ?

thanks
happy

0 Likes