[Bf-blender-cvs] [b96a360] master: Py Template: Set the active object in batch export

Campbell Barton noreply at git.blender.org
Sun Sep 21 05:23:06 CEST 2014


Commit: b96a3607ddfca3f6bcfb1c52e6cb085fb88792f0
Author: Campbell Barton
Date:   Sun Sep 21 13:16:24 2014 +1000
Branches: master
https://developer.blender.org/rBb96a3607ddfca3f6bcfb1c52e6cb085fb88792f0

Py Template: Set the active object in batch export

Some exporters (mdd for example), only use the active object

===================================================================

M	release/scripts/templates_py/batch_export.py

===================================================================

diff --git a/release/scripts/templates_py/batch_export.py b/release/scripts/templates_py/batch_export.py
index 45d26f4..6c77c5d 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




More information about the Bf-blender-cvs mailing list