Can't set influence of NLAStrip using Python #49816

Closed
opened 2016-10-22 12:49:42 +02:00 by Konstantin Dmitriev (Morevna Project) · 7 comments

Hello!

Summary of problem: When I try to set keyframe for influence parameter of NLAStrip via Python code, it doesn't works as expected.

Below I will try to describe the problem in detail.
Here is my sample file - bugreport.blend

I have a cube with two NLA strips. Top strip named "CubeAction" have Animated influence turned on.
screen-10.png

Now, I am changing its influence to 0.2. It works. In Dope Sheet I can see a keyframe created for "Influence", right under the "NLA Strip controls" group (this is because I have "Automatic keyframe insertion" turned on).

screen-11.png

I am trying to playback animation - the influence works fine.

Now, I am reloading the file (discarding all changes) and trying to do the same with the following Python code:

import bpy

#bpy.context.scene.tool_settings.use_keyframe_insert_auto = True

for object in bpy.data.objects:
    if object.animation_data:
        for track in object.animation_data.nla_tracks:
            for strip in track.strips:
                if strip.use_animated_influence:
                    print("== "+object.name)
                    print(strip.name)
                    strip.influence=0.3
                    strip.keyframe_insert(data_path="influence")

My goal is to add keyframe to influence parameter of NLA strip.

I am choosing "Text" >"Run Script" in text editor area.

After that result is the following:

screen-12.png

You can see the keyframe is added successfully, but it is on different track, outside of "NLA Strip controls" group. If I am trying to playback animation and influence doesn't applied at all - it is treated as if influence is zero

What am I doing wrong?

Hello! Summary of problem: When I try to set keyframe for influence parameter of NLAStrip via Python code, it doesn't works as expected. Below I will try to describe the problem in detail. Here is my sample file - [bugreport.blend](https://archive.blender.org/developer/F383680/bugreport.blend) I have a cube with two NLA strips. Top strip named "CubeAction" have Animated influence turned on. ![screen-10.png](https://archive.blender.org/developer/F383690/screen-10.png) Now, I am changing its influence to 0.2. It works. In Dope Sheet I can see a keyframe created for "Influence", right under the "NLA Strip controls" group (this is because I have "Automatic keyframe insertion" turned on). ![screen-11.png](https://archive.blender.org/developer/F383692/screen-11.png) I am trying to playback animation - the influence works fine. Now, I am reloading the file (discarding all changes) and trying to do the same with the following Python code: ``` import bpy #bpy.context.scene.tool_settings.use_keyframe_insert_auto = True for object in bpy.data.objects: if object.animation_data: for track in object.animation_data.nla_tracks: for strip in track.strips: if strip.use_animated_influence: print("== "+object.name) print(strip.name) strip.influence=0.3 strip.keyframe_insert(data_path="influence") ``` My goal is to add keyframe to influence parameter of NLA strip. I am choosing "Text" >"Run Script" in text editor area. After that result is the following: ![screen-12.png](https://archive.blender.org/developer/F383694/screen-12.png) You can see the keyframe is added successfully, but it is on different track, outside of "NLA Strip controls" group. If I am trying to playback animation and influence doesn't applied at all - it is treated as if influence is zero What am I doing wrong?

Changed status to: 'Open'

Changed status to: 'Open'

Added subscriber: @zelgadis

Added subscriber: @zelgadis

P.S. I am using Blender 2.78 binary build on Linux 64bit from official Blender website.

P.S. I am using Blender 2.78 binary build on Linux 64bit from official Blender website.
Member

Added subscriber: @JoshuaLeung

Added subscriber: @JoshuaLeung
Joshua Leung self-assigned this 2016-10-23 02:11:20 +02:00
Member

Ack! Looks like I forgot to force the keyframe_insert() method in the PyAPI to add these keys to the NLA Strip instead of into the action as per normal.

https://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.75/Animation#NLA_Strips_-_Local_Keyframes_for_Time_and_Influence_Controls

Ack! Looks like I forgot to force the keyframe_insert() method in the PyAPI to add these keys to the NLA Strip instead of into the action as per normal. https://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.75/Animation#NLA_Strips_-_Local_Keyframes_for_Time_and_Influence_Controls

This issue was referenced by blender/blender@3cbe95f683

This issue was referenced by blender/blender@3cbe95f68312da5320cfcfd0c6f171708b27f188
Member

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'
Sign in to join this conversation.
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender-addons#49816
No description provided.