How to set any material via python Hello I want to change the material of some objects, since it is not applied the material, I want you to apply via code in python, is a group of three materials that is just an object, I want wif the cube gets a material a sphere with another material different from the cube, and a cone with another material different from the sphere and cube.
You need a reference to the material and the object.

import bpy

# alias as D because we'll use it alot.
D = bpy.data

red_material = D.materials["Red_Material"]
cube = D.objects['Cube']
cube.active_material = red_material