STL batch export (each object as separate file)

Scripting in Blender with Python, and working on the API

Moderators: jesterKing, stiv

Post Reply
Posts: 0
Joined: Sun Apr 05, 2009 7:42 pm
Location: Germany

STL batch export (each object as separate file)

Post by CoDEmanX » Tue Jul 03, 2012 2:16 pm

i dunno where the original post has gone, where someone asked about batch stl export. He was having problems with the call



filepath is not a positional argument

you need to pass it like

and if you want to export all selected object, each into a separate file, you gotta use different code...


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

    # Clear selection    
    # Select single object = True
    # Export single object to STL
    bpy.ops.export_mesh.stl(filepath="D:\\temp\\batch_" + + ".stl")
# Restore user selection
for ob in sel_obs: = True = ob
I'm sitting, waiting, wishing, building Blender in superstition...

Post Reply