3
$\begingroup$

I'm trying to make a custom add-on, but when I try to install it from the preferences menu, it doesn't show up in the add-on menu, and the console displays :

fake_module: addon missing 'bl_info' gives bad performance!: *installed add-on file path*

Here is the entire body of code, all contained within a single file titled "skma.py" :

import bpy
#import bpy.data
import bpy.ops
from bpy.types import Menu, Operator

class SKMA(bpy.types.Operator):
    bl_idname = "mesh.skma"
    bl_label = "SKMA"
    bl_options = {'REGISTER','UNDO'}
    bl_info = {
        "name": "Shape Key Modifiers Applicator (SKMA)",
        "author": "Sisyphus Software",
        "version": (1.0),
        "blender": (3.0)
    }

    def execute(self, context):
        so = bpy.context.active_object
        if so.data.shape_keys != None:
            variants = []
            main_shape_keys = []
            shape_key_lists = []
            #make one copy of the mesh for each shape key
            for i in range(len(so.data.shape_keys.key_blocks)):
                if i != 0:
                    bpy.ops.object.duplicate_move()
                so = bpy.context.active_object
                variants.append(so)
                main_shape_keys.append(variants[i].data.shape_keys.key_blocks[i])
            for i in range(len(so.data.shape_keys.key_blocks)):
                #rename the copies as their corresponding shape keys
                if i != 0:
                    variants[i].name = variants[i].data.shape_keys.key_blocks[i].name
                variants[i].active_shape_key_index = 0
                shape_key_lists.append(variants[i].data.shape_keys.key_blocks)
                #delete all the shape keys in the correct order 
                if len(shape_key_lists[i]) > 1:
                    main_shape_key_found = 0
                    for j in range(len(shape_key_lists[i])):
                        if variants[i].data.shape_keys.key_blocks[0] == main_shape_keys[i] and main_shape_key_found == 0:
                            main_shape_key_found = 1
                        if main_shape_key_found == 0:            
                           variants[i].shape_key_remove(variants[i].data.shape_keys.key_blocks[0])
                        elif main_shape_key_found == 1 and len(variants[i].data.shape_keys.key_blocks) > 1:
                            variants[i].shape_key_remove(variants[i].data.shape_keys.key_blocks[1])
                variants[i].shape_key_remove(variants[i].data.shape_keys.key_blocks[0])
            #apply all the modifiers
            for i in range(len(variants)):
                bpy.data.objects[variants[i].name].select_set(True)
                bpy.ops.object.convert(target='MESH')
                for j in range(len(variants[i].modifiers)):
                    bpy.ops.object.modifier_apply(modifier=variants[i].modifiers[0].name)
                bpy.data.objects[variants[i].name].select_set(False)
                if i != 0:
                    bpy.data.objects[variants[i].name].select_set(True)
            #apply the copies back as shape keys to the original
            bpy.context.view_layer.objects.active = bpy.data.objects[variants[0].name]
            bpy.ops.object.join_shapes()
            #delete all the copies
            bpy.ops.object.delete()
            return{'FINISHED'}
    
    def menu_func(self, context):
        self.layout.operator(SKMA.bl_idname)
    
    def register():
        bpy.utils.register_class(SKMA)
       # bpy.types.TOPBAR_MT_app_system.append(menu_func)

def unregister():
    bpy.utils.unregister_class(SKMA)

if __name__ == '__main__':
    register()

Can you help me fix it? Thanks a lot.

$\endgroup$

1 Answer 1

3
$\begingroup$

As the message says, you're missing a bl_info structure. The "Script Meta-Info" structure looks like this:

bl_info = {
    "name": "My Script",
    "description": "Single line explaining what this script exactly does.",
    "author": "John Doe, Jane Doe",
    "version": (1, 0),
    "blender": (2, 65, 0),
    "location": "View3D > Add > Mesh",
    "warning": "", # used for warning icon and text in addons panel
    "doc_url": "http://wiki.blender.org/index.php/Extensions:2.6/Py/"
                "Scripts/My_Script",
    "tracker_url": "https://developer.blender.org/maniphest/task/edit/form/2/",
    "support": "COMMUNITY",
    "category": "Add Mesh",
}

and is described in the wiki entry mentioned above. It goes before the import bpy statement and is required for an add-on.

It's very short, but I definitely recommend reading the "Add-On Tutorial" page of the manual before starting out on your first add-on.

I also recommend Scripting for Artists from the Blender foundation. Most of it is free from the foundation and can also be found on YouTube.

$\endgroup$
2
  • 1
    $\begingroup$ It worked, thank you! $\endgroup$
    – user46965
    Commented Mar 25, 2022 at 20:32
  • 1
    $\begingroup$ @user46965 you're welcome. Enjoy writing add-ons. $\endgroup$ Commented Mar 25, 2022 at 20:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .