Exporting from Blender all the objects into multiple files for Unity

Hi, i’ve modeled all my objects into a Blender scene, now i want to export them (preferably fbx format) all in batch but i want each one to be a single file (fbx file for example, with the name of the object as filename).

If i use the blender fbx exporter, all the objects are exported into a single fbx and are imported into blender as an object which contains multiple subobjects. And i don’t like this.

Is there a way, or an already made script (where?) that i can use to do that ? If not possible with fbx format also other formats supported by Unity are ok.

Also i’ve another question: i’m wonder which is the best way to export all the objects inside a blender scene, with each one having 0,0,0 location. What i mean is that if i’ve them in blender positioned at different location for each object, this location is kept, stored and exported in the fbx file (then imported into blender). Instead i want all objects to be positioned by default at 0,0,0. I know i can do “Reset location” in blender, but it’s a time wasting to do that on each object before exporting it, and the restoring back to the original position after exporting it.

What is the best workflow to export all the objects into separate files, and each one having 0,0,0 location ?

Thanks!

I wish I had found this question earlier. Just wrote a plugin for blender which does batch export among other things.

You can choose the destination folder where to store the exported fbx files.

Have fun

This really sounds like a Blender question rather than a Unity question.

I’m not a Blender expert, but I do know that it’s relatively trivial to script Blender via its Python API interface.

Untested and probably wrong, but what you want is something like this:

import bpy

# access the scene
scene = bpy.context.scene

# start with empty selection
bpy.ops.object.select_all(action='DESELECT')    

# loop through all objects in the scene
for ob in scene.objects:

    # select this object
    scene.objects.active = ob
    ob.select = True

    # if this object is a mesh
    if ob.type == 'MESH':

        # export to FBX
        bpy.ops.export_scene.fbx(filepath=ob.name + '.fbx'), use_selection=True)

    # deselect this object again
    ob.select = False