Skip to main content
unregister_module was deprecated
Source Link
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_moduleunregister_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()

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_module(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()

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()
2.8x update
Source Link
brockmann
  • 12.8k
  • 4
  • 51
  • 94

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_module(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()
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()

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_module(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()
added 55 characters in body
Source Link
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()
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():
   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()
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()
elaborated more
Source Link
Loading
Source Link
Loading