bpy.ops.export_mesh.stl(str)
----------------------
filepath is not a positional argument
you need to pass it like
bpy.ops.export_mesh.stl(filepath=str)
and if you want to export all selected object, each into a separate file, you gotta use different code...
e.g.
Code: Select all
import bpy
# Keep a copy of user selection
sel_obs = bpy.context.selected_objects[:]
for ob in sel_obs:
# Skip non-mesh objects
if ob.type != 'MESH':
continue
# Clear selection
bpy.ops.object.select_all(action="DESELECT")
# Select single object
ob.select = True
# Export single object to STL
bpy.ops.export_mesh.stl(filepath="D:\\temp\\batch_" + ob.name + ".stl")
# Restore user selection
for ob in sel_obs:
ob.select = True
bpy.context.scene.objects.active = ob