Fix [#32135] FRAMERATE: Framerate display is truncated in selection box.
[blender.git] / release / scripts / templates / batch_export.py
1 # exports each selected object into its own file
2
3 import bpy
4 import os
5
6 # export to blend file location
7 basedir = os.path.dirname(bpy.data.filepath)
8
9 if not basedir:
10     raise Exception("Blend file is not saved")
11
12 selection = bpy.context.selected_objects
13
14 bpy.ops.object.select_all(action='DESELECT')
15
16 for obj in selection:
17
18     obj.select = True
19
20     name = bpy.path.clean_name(obj.name)
21     fn = os.path.join(basedir, name)
22
23     bpy.ops.export_scene.fbx(filepath=fn + ".fbx", use_selection=True)
24
25     ## Can be used for multiple formats
26     # bpy.ops.export_scene.x3d(filepath=fn + ".x3d", use_selection=True)
27
28     obj.select = False
29
30     print("written:", fn)
31
32 for obj in selection:
33     obj.select = True