Previous Thread  Next Thread

chat icon STL batch export (each object as separate file)

CoDEmanX

Posted: Tue Jul 03, 2012 1:16 pm
Joined: 05 Apr 2009
Posts: 693
i dunno where the original post has gone, where someone asked about batch stl export. He was having problems with the call

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:
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

_________________
I'm sitting, waiting, wishing, building Blender in superstition...
Reply with quote


 
Jump to:  
Powered by phpBB © 2001, 2005 phpBB Group