Skip to main content
5 of 5
unregister_module was deprecated
Gorgious
  • 31.8k
  • 2
  • 50
  • 106

Blender 2.8x

def menu_func(self, context):
    self.layout.operator("YOUR OPERATOR BL_IDNAME")
    # bl_idname should be in form of "something.something"
    # or YourClass.bl_idname

def register():
   # register classes so blender knows about them
   bpy.utils.register_class(MyOperatorClass)
   # this adds your menu to shift-a add object menu
   bpy.types.VIEW3D_MT_add.prepend(menu_func)
   # if you want to add to mesh menu use INFO_MT_mesh_add
   # other menu classes you can find in \scripts\startup\bl_ui\
   # by looking into the files there (i.e.: space_view3d.py)

def unregister():
    bpy.utils.unregister_class(MyOperatorClass)
    bpy.types.VIEW3D_MT_add.remove(menu_func)

if __name__ == "__main__":
    register()

Blender 2.7x

def menu_func(self, context):
    self.layout.operator("YOUR OPERATOR BL_IDNAME")
    # bl_idname should be in form of "something.something"
    # or YourClass.bl_idname

def register():
   # register classes so blender knows about them
   bpy.utils.register_module(__name__)
   # this adds your menu to shift-a add object menu
   bpy.types.INFO_MT_add.prepend(menu_func)
   # if you want to add to mesh menu use INFO_MT_mesh_add
   # other menu classes you can find in \scripts\startup\bl_ui\
   # by looking into the files there (i.e.: space_view3d.py)
 
def unregister():
    bpy.utils.unregister_module(__name__)
    bpy.types.INFO_MT_add.remove(menu_func)

if __name__ == "__main__":
    register()