I have some meshes in the scene (7 mesh objects for example). I want to assign each object a color. The color should vary in a specific scale. For example: green scale. So, first object has green value 0.1, second 0.2 and so on. So in the end, I can able to see a pattern of color.
All this I want as a BoolProperty checkbox button in my UI Panel. So, when I check it, it should show me colors and vice versa.
def switch(self, context):
bool = context.scene.bool
objects = bpy.data.objects
mat = bpy.data.materials['Material']
if bool == True:
print ("True")
for ind, object in enumerate(bpy.context.scene.objects):
mat = bpy.data.materials.new("BSDF")
val = 0.0
mat.diffuse_color = (float(val), 1, float(val))
object[ind].active_material = mat
val += .1
else:
for ind, object in enumerate(bpy.context.scene.objects):
object[ind].active_material.delete()
This is what I want to achieve but it's not working.
Object.active_material.delete()
? $\endgroup$