So ,I was trying to create a 3dview custom menu to easily access Grease pencil data like colors ,layers etc .However these properties didn't have any unique label but a common label called "null" . eg. bpy.data.grease_pencil["GPencil"].(null) = 0,1,2 .... (same label for both GPencil colors and GPencil layers ).

Is their any way to access and operate on such type of data?

  • $\begingroup$ Related When you see Foo.(null) it is a case where the property name is unknown (eg should be foo.bar) or an error has occurred when displaying. Using autocomplete in python console is a quick way to find property names and values. $\endgroup$ – batFINGER Sep 29 '18 at 11:44

I did dig into the gpencil null object prop issue and my best guess is that this exists because a gpencil color is not a float RGB values list but a collection of two set of props - strokecolor and fillcolor. I am not sure how to access a collection like in case of a gpencil color.I did try using context_pointer_set function to point to the activepalette colors index.The code is given below but it gives an context attribute error.

import bpy class GPcolorMenu(bpy.types.Menu): bl_label = “GPcolors” bl_idname = “gpencil.GPcolor_menu”

Copy to clipboard def draw(self, context): layout = self.layout

for color in bpy.data.grease_pencil["GPencil"].palettes["GP_Palette"].colors:

    row = layout.row()

    row.context_pointer_set("active_palettecolors", color) 
    layout.menu(context.active_palettecolors, text=color.name)

def register(): bpy.utils.register_module(name)

def unregister(): bpy.utils.unregister_module(name)

if name == “main”: register()


| 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.