EDIT: as of yet I haven't been able to find a concrete example of someone using an addon exporter in a python script, so if any of you have that I would be very grateful!
I have hundreds of files and I'm using a small script to standardize them and convert them to .json files for use in three.js, but I can't get the exporter to work. It is throwing an error (evidently a different one than ImportError) at bpy.ops.wm.addon_expand(module="three") - when I mouse over the addon in the "export" submenu, it gives me the bpy.ops.export.three(filepath = "export path") operation as how to access it, but it is still throwing errors. Here's my testing code:
import bpy
import addon_utils
def main():
cube = bpy.data.objects[1]
bpy.ops.object.delete()
# import
filePath = "import path"
bpy.ops.import_scene.obj(filepath=filePath)
tablet = bpy.data.objects[1]
# find dimensions and scale accordingly
tabletDimensions = tablet.dimensions
scale = min(10/tabletDimensions[0],10/tabletDimensions[1],10/tabletDimensions[2])
# give 3dcursor new coordinates
bpy.context.scene.cursor_location = (0.0,0.0,0.0)
# set the origin on the current object to the 3dcursor location
bpy.ops.object.origin_set(type='GEOMETRY_ORIGIN')
tablet.scale = (scale,scale,scale)
print(addon_utils.paths())
try:
bpy.ops.wm.addon_expand(module="three")
bpy.ops.export.three(filepath = "export path")
except ImportError:
print("Threejs importer addon not available")
#bpy.ops.mesh.primitive_uv_sphere_add(size=2,location=(5,5,5))
main()
bpy.ops.wm.addon_expand(...)only expands the addon details in the UI, it doesn't install nor enable the addon. – batFINGER Dec 15 '15 at 16:46