Why are my classes and functions not working in Blender 2.8? The buttons I created stopped working, they worked in blender 2.79. By the way, the standard buttons work, but my not. Any thoughts on this? Please tell me what could be the reason. Thank!

Button example:

class ALLSELECTDELETE_PT_operator(bpy.types.Operator):
"""All select and delete"""
bl_label = "Delete all"
bl_idname = "object.all_select_delete"
bl_description = "All select and delete"

def execute(self, context):

    bpy.ops.object.mode_set(mode='OBJECT')
    bpy.ops.object.select_all(action='SELECT')
    bpy.ops.object.delete(use_global=False)
    bpy.ops.view3d.snap_cursor_to_center()
Look in system console for errors

Start blender from a system console and note any error or warning messages that pop up during registration.

Where does console output go

How to view python error messages?

Blender 2.8 has a far stricter naming convention for operators and panels.  The operator with bl_idname = foo.bar should be given the class name FOO_OT_bar  (_OT_ indicates "Operator Type")

Here is an adjustment to the code, I have prepended the button to the 3DView header to test.



import bpy

class OBJECT_OT_all_select_delete(bpy.types.Operator):
    """All select and delete"""
    bl_label = "Delete all"
    bl_idname = "object.all_select_delete"
    bl_description = "All select and delete"

    def execute(self, context):

        bpy.ops.object.mode_set(mode='OBJECT')
        bpy.ops.object.select_all(action='SELECT')
        bpy.ops.object.delete(use_global=False)
        bpy.ops.view3d.snap_cursor_to_center()

def draw_button(self, context):
    self.layout.operator("object.all_select_delete")

def register():
    bpy.utils.register_class(OBJECT_OT_all_select_delete)
    bpy.types.VIEW3D_HT_header.prepend(draw_button)

if __name__ == "__main__":
    register()