How can I create a new material and set it active material on the active object using python script.
1 Answer
$\begingroup$
$\endgroup$
1
You could do it like this:
obj = bpy.context.object # Select the active object.
mat = bpy.data.materials.new(name='Material') # Create a material.
# Settings for the material go here.
obj.data.materials.append(mat) # Assign the new material.
-
1$\begingroup$ bpy.ops.material.new(name='zz') now gives me 'keyword "name" unrecognized' in blender 2.9 $\endgroup$– james_tCommented Aug 2, 2021 at 19:27