0
$\begingroup$

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()
$\endgroup$
0
$\begingroup$

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()
$\endgroup$
  • $\begingroup$ 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? $\endgroup$ – Алексей Неважно Feb 6 at 4:19
  • $\begingroup$ There are other files, with standard buttons interleaved with mine, standard ones are imported, but mine aren’t $\endgroup$ – Алексей Неважно Feb 6 at 4:25
  • $\begingroup$ 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. $\endgroup$ – batFINGER Feb 6 at 7:21
  • $\begingroup$ It could for instance be broken poll methods. $\endgroup$ – batFINGER Feb 6 at 7:28
  • $\begingroup$ 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' $\endgroup$ – Алексей Неважно Feb 6 at 9:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.