From b96a3607ddfca3f6bcfb1c52e6cb085fb88792f0 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 21 Sep 2014 13:16:24 +1000 Subject: [PATCH] Py Template: Set the active object in batch export Some exporters (mdd for example), only use the active object --- release/scripts/templates_py/batch_export.py | 9 +++++++++ 1 file changed, 9 insertions(+) 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