So,I was looking to accelerate the coloring workflow in grease pencil by creating a custom menu of the active GP palette colors. The workflow would be to assign a hotkey to this custom menu and then invoke it while coloring.I have scripted a Python code for this purpose andfacing the following issues-
1.Since GPcolors are array of RGB values(correct me if I am wrong) couldn’t find any pointer functions to point to array values. 2.The code when run indicates an endless loop of menus. Any suggestions would help.The code is given below-
import bpy
class GPcolorMenu(bpy.types.Menu):
bl_label = "GPcolors"
bl_idname = "gpencil.GPcolor_menu"
def draw(self, context):
layout = self.layout
for color in bpy.data.grease_pencil["GPencil"].palettes["GP_Palette"].colors:
layout.menu(GPcolorMenu.bl_idname, text=color.name)
def register():
bpy.utils.register_module(__name__)
def unregister():
bpy.utils.unregister_module(__name__)
if __name__ == "__main__":
register()
bpy.ops.wm.call_menu(name=GPcolorMenu.bl_idname)