Call custom menu action using python I'm using Blender 2.80 with an add-on (not developed by me). This add-on add some new functionalities and allow the user to export the scene with a custom extension (to do this it add a new option in File --> Export).

Now I'm developing a new python script able to open a new blender scene, make some actions and then save it using that custom extension but I don't know how to call a custom export option.

Briefly this is what I've done till now:

import os
import bpy

bpy.ops.wm.open_mainfile(filepath="path//to//file.blend")

# some actions...

# not what I want since this export the scene as obj file...
bpy.ops.export_scene.obj(filepath="path//to//target.obj")
You just need to swap your last call with the one you want to use.

For example if you want to export to gltf use

bpy.ops.export_scene.gltf(filepath='path/to/file.gltf')


For stl its

bpy.ops.export_mesh.stl(filepath='path/to/file.stl')


If you get an error when running the script, that may mean that the addon is not enabled. You can use the addon_utils module to enable an addon.

import addon_utils
addon_utils.enable('addon_name')


where "addon_name" is the addons file/folder name within the addons folder.

You can also enable addons on the CLI when starting blender.

blender -b -addons io_scene_3ds,io_import_dxf file.blend -P script.py