1
$\begingroup$

enter image description here

I have 784 cubes in my scene right now, and I can loop through all 784 of them by using

for i in range(784):
    bpy.data.objects[i]

Each cube represents a pixel which is in grayscale color, a value between 0.0 to 1.0. I already have my colors extracted from a 2D grayscale image and now I just want to transfer the corresponding brightness value to the cubes. Basically, do:

bpy.data.objects[i].find_its_color_options.change_brightness_to(0.873)

and repeat for all 784 cubes. I am currently using blender 2.8 but I don't think this is going to be much different than 2.79.

Any help is appreciated!

$\endgroup$
2
$\begingroup$

If you use in bpy.data.objects.active_material.material.diffuse_color you can set the diffuse color, and there are some other properties that may be useful here and here

In my experience, materials are tricky with scripts. You need to remember that materials are separate from the objects, so if the same material is assigned to every cube, changing it for one material will change it for all of them.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.