3
$\begingroup$

I have 20 different strips on the NLA editor, and am trying to render all of them.

How do I:

  1. Render each strip seperately into it's own output folder
  2. Render only active frames/keyframes

Python looks promising, but I was wondering if anyone could give a few hints on the methods needed.

Something along the lines of:

for strip in nla.getstrips()
{
   dopesheet.add( strip );

   active_frames = dopesheet.getKeyFrames();

   start_frame = active_frames.first();
   finish_frame= active_frames.last();

   render( dopesheet, 
        range = [start_frame, end_frame], 
        outfolder = strip.name()
   );

   dopesheet.remove( strip );
}
$\endgroup$
  • 1
    $\begingroup$ Do any nla strips overlap? do you want any overlapping strips to render separately? For skipping still frames this answer may help. $\endgroup$ – sambler Jan 11 '16 at 7:48
  • $\begingroup$ Yes, many strips do overlap (multiple paths an animation can take), and yes overlapping strips should NOT mix and should be kept seperate please $\endgroup$ – tetris11 Jan 11 '16 at 9:35
3
$\begingroup$

Looking at 1. to render each strip into it's own folder we can make a list of each nla strip, here I store the mute setting to restore later and mute each strip as we go through.

Then loop through our list of strips and render the frame range of each one, by setting the render.filepath here each strip can go into it's own folder.

To also achieve 2. you could look at the script in this answer and incorporate it into the rendering loop.

import bpy

output_dir = '//renders/'
scene = bpy.context.scene

# make a list of strips used in the NLA
# strips are found in -
# object.animation_data.nla_tracks[TrackName].strips[stripName]
nla_strips = []
for obj in scene.objects:
    if obj.animation_data and obj.animation_data.nla_tracks:
        for track in obj.animation_data.nla_tracks:
            for strip in track.strips:
                nla_strips.append((strip, strip.mute))
                strip.mute = True

# save to restore later
orig_frame_start = scene.frame_start
orig_frame_end = scene.frame_end
orig_filepath = scene.render.filepath

# render each strip
for strip in nla_strips:
    scene.render.filepath = output_dir + strip[0].name + '/'
    scene.frame_start = strip[0].frame_start
    scene.frame_end = strip[0].frame_end
    strip[0].mute = False
    bpy.ops.render.render(animation=True)
    strip[0].mute = True

# restore changes we made
scene.frame_start = orig_frame_start
scene.frame_end = orig_frame_end
scene.render.filepath = orig_filepath

for strip in nla_strips:
    strip[0].mute = strip[1]
$\endgroup$
  • $\begingroup$ Brilliant! You did the hard part - I can totally finish this on my own! $\endgroup$ – tetris11 Jan 11 '16 at 12:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.