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>2014-09-21 07:16:24 +0400
committerCampbell Barton <ideasman42@gmail.com>2014-09-21 07:20:46 +0400
commitb96a3607ddfca3f6bcfb1c52e6cb085fb88792f0 (patch)
tree61a1c357795c8070d4a378d609b091a9dfbeafb0 /release
parenta0b36043376507aadd792905845c15e59a4b8a0b (diff)
Py Template: Set the active object in batch export
Some exporters (mdd for example), only use the active object
Diffstat (limited to 'release')
-rw-r--r--release/scripts/templates_py/batch_export.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/release/scripts/templates_py/batch_export.py b/release/scripts/templates_py/batch_export.py
index 45d26f4b525..6c77c5d6a1a 100644
--- a/release/scripts/templates_py/batch_export.py
+++ b/release/scripts/templates_py/batch_export.py
@@ -9,6 +9,9 @@ basedir = os.path.dirname(bpy.data.filepath)
if not basedir:
raise Exception("Blend file is not saved")
+scene = bpy.context.scene
+
+obj_active = scene.objects.active
selection = bpy.context.selected_objects
bpy.ops.object.select_all(action='DESELECT')
@@ -17,6 +20,9 @@ for obj in selection:
obj.select = True
+ # some exporters only use the active object
+ scene.objects.active = obj
+
name = bpy.path.clean_name(obj.name)
fn = os.path.join(basedir, name)
@@ -29,5 +35,8 @@ for obj in selection:
print("written:", fn)
+
+scene.objects.active = obj_active
+
for obj in selection:
obj.select = True