Add a Driver to all NLA strips in a scene

Ok one more question guys.

If I have about 100 NLA strips, and I want to assign one driver with particular values to all their “playback scales”.

for example I have this:


and I am trying to apply this to all of them:

  1. Add driver to playback scale
  2. Set the driver to “Sum Values”
  3. Specify the name of the Controlling object
  4. Set the type of transform channel to Z location


I am trying to add simply a driver to one of the actions and it is asking me for the path, and it is stumping me there. Basically because I have no idea how to get the path it needs to add the driver.
Example:

bpy.context.scene.objects[‘Icosphere.001’].animation_data.nla_tracks[‘NlaTrack.001’].strips[‘BashME_2’].driver_add(path, index= -1)

if there was a copy and paste function for the drivers this would be so much easier…

A word of warning: Since drivers can only ever run after all the animation in the scene has been evaluated, this will NOT update correctly for most cases. I’d advise against trying to do this for any of these settings.

This is the closest you can get:

import bpy

for ob in bpy.context.scene.objects:
    if ob.animation_data is not None:
        action = ob.animation_data.action
        if action is not None:
            track = ob.animation_data.nla_tracks.new()
            strip = track.strips.new(action.name, action.frame_range[0], action)
            ob.animation_data.action = None
            fcurve = strip.driver_add("scale")
            driver = fcurve.driver
            driver.type = 'SUM'
            var = driver.variables.new()
            var.type = 'TRANSFORMS'
            #var.targets # <-- has no .new() and there's really no way to do this :/

driver targets can’t be created by python, the RNA methods are missing :frowning:

yep that seems to be the limit. I’m giving up on this one.