mirror of
https://github.com/blender/blender
synced 2026-09-29 04:37:17 +03:00
Py Template: Set the active object in batch export
Some exporters (mdd for example), only use the active object
This commit is contained in:
parent
a0b3604337
commit
b96a3607dd
1 changed files with 9 additions and 0 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue