How can I create a new material and set it active material on the active object using python script.


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.
| improve this answer | |

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.