Py Template: Set the active object in batch export
Some exporters (mdd for example), only use the active object
This commit is contained in:
@@ -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
|
||||
|
Reference in New Issue
Block a user