Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2011-07-17 17:29:50 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-07-17 17:29:50 +0400
commit7e4ccf9349ad7444e43421a012c8b21b23c57ab6 (patch)
tree43f6db6620e547ea0e93f7c69969b8a92ebd5939 /release/scripts/templates
parentc7532c5b812d411a8457e0693dc4038b3da9b901 (diff)
template for patch exporting objects in a scene.
Diffstat (limited to 'release/scripts/templates')
-rw-r--r--release/scripts/templates/batch_export.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/release/scripts/templates/batch_export.py b/release/scripts/templates/batch_export.py
new file mode 100644
index 00000000000..aa0e601725b
--- /dev/null
+++ b/release/scripts/templates/batch_export.py
@@ -0,0 +1,33 @@
+# exports each selected object into its own file
+
+import bpy
+import os
+
+# export to blend file location
+basedir = os.path.dirname(bpy.data.filepath)
+
+if not basedir:
+ raise Exception("Blend file is not saved")
+
+selection = bpy.context.selected_objects
+
+bpy.ops.object.select_all(action='DESELECT')
+
+for obj in selection:
+
+ obj.select = True
+
+ name = bpy.path.clean_name(obj.name)
+ fn = os.path.join(basedir, name)
+
+ bpy.ops.export_scene.fbx(filepath=fn + ".fbx", use_selection=True)
+
+ ## Can be used for multiple formats
+ # bpy.ops.export_scene.x3d(filepath=fn + ".x3d", use_selection=True)
+
+ obj.select = False
+
+ print("written:", fn)
+
+for obj in selection:
+ obj.select = True