I have added a grease pencil and need to add a new material slot in python. I have used this script for active objects, however I am missing something with the grease pencil.

activeObject = bpy.context.active_object 
mat = bpy.data.materials.new(name="MaterialName") 

bpy.context.object.active_material.diffuse_color = (0.121583, 0.144091, 0.8, 0.729885)

The script below enables you to add a new material slot for your active grease pencil.

import bpy

ob = bpy.context.active_object  # Must be a GPencil object
mat = bpy.data.materials.new(name="Mymaterial")
  • 2
    $\begingroup$ Hi Michael! Can you please add any explanation to your answer to make it more useful? Thanks $\endgroup$
    – p2or
    Feb 15 '20 at 9:14

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.