So,I was looking to accelerate the coloring workflow in grease pencil by creating a custom menu of the active GP palette colors.I have scripted a Python code for this purpose and was facing the following issues-
1.Since GPcolors are stored as index values as a combination of stroke and fill color arrays (correct me if I am wrong) I couldn’t find any pointer functions to index 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:
#tried using bpy.context above but gave an attribute error
layout.menu(GPcolorMenu.bl_idname, text=color.name)
#could not find any pointer function to display and select 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)