Creating panels that are only available for specific object


I was going through some examples on how to create panels, menus, popups etc. in Blender 2.8.

However, either I’ve missed the fact, but to me at first glance it only seems possible to create panels that exist always in some location (like N panel tab), and not only when some object is selected?

For example, if I were to create some rigging related addon, I would only like have the tab appear in properties window or N panel tab when a certain rig object is selected.

Is this possible?

I would say that it’s possible but you would have to register and unregister the panel, based on some select event, maybe it’s “too much” for what you want to do.
A much simpler trick would be to add a condition in the draw function.
Here is an example with the default ui_panel_simple template :

import bpy

class HelloWorldPanel(bpy.types.Panel):
    """Creates a Panel in the Object properties window"""
    bl_label = "Hello World Panel"
    bl_idname = "OBJECT_PT_hello"
    bl_space_type = 'PROPERTIES'
    bl_region_type = 'WINDOW'
    bl_context = "object"

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

        obj = context.object
            row = layout.row()
            row.label(text="Hello world!", icon='WORLD_DATA')

            row = layout.row()
            row.label(text="Active object is: " +
            row = layout.row()
            row.prop(obj, "name")

            row = layout.row()

def register():

def unregister():

if __name__ == "__main__":

I only added the line 16 : if"Cube":
It means when context object is not the “Cube”, it won’t draw anything.
As you wan see here :

See you :slight_smile: ++

1 Like


Thank you for your reply!

I think I could live with that header still there.

Based on what I’ve read, I think it would also be possible to store object’s name to some custom property / PropertyGroup (not exactly sure of all of these yet) instead of hard coded string comparison… ?


You don’t need to… If you want the whole panel to hide, instead of doing a condition check in the draw method, it’s better to use the poll function (which serves exactly to check if the context is valid for the panel to be called).

def poll(cls, context):
    return == "Cube"

This will bypass the whole panel when is different than ‘Cube’.

1 Like