Hi guys, I am using the following code to duplicate an object and assign materials according to its name.
for filename in dir
bpy.data.objects['Cube'].copy()
bpy.context.scene.objects.link(bpy.data.objects['Cube.001'])
bpy.data.objects['Cube.001'].name = 'Cube'+filename
#change the material of the newly created object by filename
bpy.data.objects['Cube'+filename].data.materials[2] = .......
However, every duplicated objects created in this method is having the same material, the last one assigned in the for loop.
Even when I try to change it in the material tab manually, all the objects’s material is changed by this action.
Is there anyway for me to duplicate an object by the method of copy() but at the same time ensure that the materials are not linked so each one has its own material?
