0
$\begingroup$

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")
$\endgroup$
2
  • 1
    $\begingroup$ And what you'd like to do? In other words: What's your question? Also have a look into the python templates: Templates > Python > Operator Export might be interesting. $\endgroup$
    – brockmann
    Sep 17, 2019 at 12:06
  • $\begingroup$ In order to add new export options that add-on would have to add new operators. You can check for the name of the operator by activating Python tooltips (Edit > Preferences > Interface) in the preferences and then hover with your mouse over the menu entry for the export format. $\endgroup$
    – Robert Gützkow
    Sep 17, 2019 at 12:09

1 Answer 1

0
$\begingroup$

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
$\endgroup$

You must log in to answer this question.

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