Reply To: [Python Scripting] Transitioning from Blender 2.7x to 2.8x

Forum Archive [Python Scripting] Transitioning from Blender 2.7x to 2.8x Reply To: [Python Scripting] Transitioning from Blender 2.7x to 2.8x

#68965
Ryan Sweeney
Participant

    Ah fun! Discovered that `INFO_MT_mesh_add` was replaced with `VIEW3D_MT_mesh_add` when adding an item to the mesh menu. Couldn’t find documentation on this but at least the templates in the text editor are up to date.

    So old code for registering a module now changes to adding a class.
    Old way:

    def register():
        bpy.utils.register_module(__name__)
        bpy.types.INFO_MT_mesh_add.append(menu_func)
        
    def unregister():
        bpy.utils.unregister_module(__name__)
        bpy.types.INFO_MT_mesh_add.remove(menu_func)
    

    New Way:

    def register():
        from bpy.utils import register_class
        register_class(ClassName)
        bpy.types.VIEW3D_MT_mesh_add.append(menu_func)
    
    
    def unregister():
        from bpy.utils import unregister_class
        unregister_class(ClassName)
        bpy.types.VIEW3D_MT_mesh_add.remove(menu_func)