7
$\begingroup$

Can you please tell me how to remake it for Blender 2.8x version?

def register():
    bpy.utils.register_module(__name__)
    bpy.types.INFO_MT_file_export.append(menu_func_export)
def unregister():
    bpy.utils.unregister_module(__name__)
    bpy.types.INFO_MT_file_export.remove(menu_func_export)
if __name__ == "__main__":
    register()
$\endgroup$
1

1 Answer 1

11
$\begingroup$

There is two things to consider. First, API changes have been made, and one of the decisions was to remove the register_module() and unregister_module() convenience functions. The code below is an excerpt from the more detailed Release Notes of Blender 2.80 (https://wiki.blender.org/wiki/Reference/Release_Notes/2.80/Python_API/Addons#Registration):

classes = (
    FooClass,
    BarClass,
    BazClass,
)

def register():
    from bpy.utils import register_class
    for cls in classes:
        register_class(cls)

def unregister():
    from bpy.utils import unregister_class
    for cls in reversed(classes):
        unregister_class(cls)

Second, the INFO_MT_file_export has been moved to TOPBAR_MT_file_export. So your code should be this in the end:

__classes__ = (
    list_of_classes_you_have
)

def register():
    for c in __classes__:
        bpy.utils.register_class(c)
    bpy.types.TOPBAR_MT_file_export.append(menu_func_export)
def unregister():
    for c in reversed(__classes__):
        bpy.utils.unregister_class(c)
    bpy.types.TOPBAR_MT_file_export.remove(menu_func_export)
if __name__ == "__main__":
    register()
$\endgroup$

You must log in to answer this question.

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