I have created a custom panel and when N is pressed on the keyboard in 3d view we get the Sidebar with the Item tab opened by default, but I don't want that. I have also added an operator that does the same as N but I want to add one more thing that I could not find.
When someone presses N or executes my operator by pressing Shift+N it should open the Sidebar tab with my add-on.
import bpy
class MY_PT_PANEL(bpy.types.Panel):
bl_label = "My Addon"
bl_idname = "MY_PT_TAB"
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
bl_category = "MyTab"
def draw(self, context):
layout = self.layout
layout.label(text='Welcome to my addon',icon='FORWARD')
class MY_OT_OPERATOR(bpy.types.Operator):
bl_idname='addon.open_sidebar'
bl_label = 'Open SideBar'
def execute(self,context):
areas = bpy.context.screen.areas
view_3d = None
for area in areas:
if area.type == 'VIEW_3D':
view_3d = area
space = view_3d.spaces[0]
space.show_gizmo = False
space.show_region_ui = True
return {'FINISHED'}
addon_keymap = []
def register():
bpy.utils.register_class(MY_PT_PANEL)
bpy.utils.register_class(MY_OT_OPERATOR)
wm = bpy.context.window_manager
kc = wm.keyconfigs.addon
km = kc.keymaps.new('3D View', space_type = 'VIEW_3D')
kmi = km.keymap_items.new('addon.open_sidebar','N','PRESS',shift=True)
addon_keymap.append((km,kmi))
def unregister():
bpy.utils.unregister_class(MY_PT_PANEL)
bpy.utils.unregister_class(MY_OT_OPERATOR)
wm = bpy.context.window_manager
kc = wm.keyconfigs.addon
for km, kmi in addon_keymap:
km.keymap_items.remove(kmi)
addon_keymap.clear()
if __name__ == "__main__":
register()
```
N
it opens theItem
tab which I don't. I should open another tab likeView
orTool
or my addon. $\endgroup$