0
$\begingroup$

I’m trying to add custom panel to the Texture Paint tools on the Properties tab, it’s suppoesd to be a simple task, but from some reason it’s doesn’t really work. I think the problem is on the bl_context property, When I’m trying using it with other contexts like object it works, but not with the PAINT_TEXTURE.

Code:

class BM_MU_mask_textures_menu(bpy.types.Panel):
    bl_label = "My Texture Panel"
    bl_idname = "PT_SimpleTexturePanel"
    bl_space_type = 'PROPERTIES'
    bl_region_type = 'WINDOW'
    bl_context = "PAINT_TEXTURE"


    def draw(self, context):
        layout = self.layout

$\endgroup$

1 Answer 1

0
$\begingroup$

This is a special properties editor, it is drawn both in the 3D viewport and in the Tool properties editor. So you need to register it in the 3D viewport space. You can choose to only display it when you're in texture paint mode with the active object with the operator poll method.

import bpy


class HelloWorldPanel(bpy.types.Panel):
    bl_label = "My Texture Panel"
    bl_idname = "PT_SimpleTexturePanel"
    bl_region_type = "UI"
    bl_space_type = "VIEW_3D"
    bl_category = "Tool"
    
    @classmethod
    def poll(cls, context):
        return getattr(context, "active_object", False) and context.active_object.mode == "TEXTURE_PAINT"

    def draw(self, context):
        self.layout.label(text="My text")


def register():
    bpy.utils.register_class(HelloWorldPanel)


if __name__ == "__main__":
    register()

enter image description here

$\endgroup$
1
  • $\begingroup$ Thanks! Is there any way to register it also on the top header bar? like. an icon and a text that shows the panel when you click it. $\endgroup$ Dec 11, 2023 at 15:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .