0

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()
Nembus
  • 91
  • 1
  • 7

1 Answers1

2

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.

enter image description here

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()
batFINGER
  • 84,216
  • 10
  • 108
  • 233
  • I have the init.py file and the allselectdelete.py file with this button, and for some reason init.py stopped calling the button, although everything is fine in 2.79 blender. Maybe something has changed with the import? – Nembus Feb 06 '19 at 04:19
  • There are other files, with standard buttons interleaved with mine, standard ones are imported, but mine aren’t – Nembus Feb 06 '19 at 04:25
  • All there is to go on is the code you posted in question. Demonstrated that after some minor adjustments the button renders fine in the 2.8 UI. Suggest pasting pertinent code in question, and / or a link to your full code. Start blender from a system console and note any error or warning messages that pop up during registration. – batFINGER Feb 06 '19 at 07:21
  • It could for instance be broken poll methods. – batFINGER Feb 06 '19 at 07:28
  • For some reason, the blender 2.8 does not see my buttons, this error was detected in the console

    C:\Users\admin\AppData\Roaming\Blender Foundation\Blender\2.80\scripts\addons********__init__.py:124 rna_uiItemO: operator missing srna 'bones.wings_enable'

    – Nembus Feb 06 '19 at 09:00
  • Since it appears both the code is secret, and its name scripts\addons********_init_.py is secret I cannot help further. – batFINGER Feb 06 '19 at 09:08
  • The name of the addon is classified, I don’t want to advertise it – Nembus Feb 06 '19 at 09:14