NLA Editor: Make a strip active

Hello,

I have a rather simple question. I have found out how to do a script active, manually, but pushing the snowflake as you can see in the picture
.

The thing is that I can’t find in the documentation how to do it by script…I am quite confused…

any idea?

If there is no way to do that using a command, is there a way to add action clip to the nla editor, in order to make the same human make more than one movements, again by script???

Thanks in advance!:slight_smile:

Here is a simple little script that adds a new track/strip for the context object that already has an action.


import bpy

context = bpy.context
object = context.object
scene = context.scene
frame = scene.frame_current
action = context.object.animation_data.action

# add an NLA track

newtrack = object.animation_data.nla_tracks.new()
newtrack.name = "NLATRACK"

# add a new Strip at current frame 

strip = newtrack.strips.new(name=action.name, start=frame, action=action) 

Hey:)))

Thanks a lot, because yesterday I got confused. The thing now is that I have the latest imported action and I want to delete it…

I have tried

bpy.ops.action.delete()

after the code that you proposed but it erases the latest action that I import, both nlatrack and act action…

could you propose smth about that too?:)))))

Do you want to delete it or remove it from the slot?


object = bpy.context.object
object.animation_data.action = None


You are a life savior!!! I just wan to press x, from animation data…this means unlinking? I am not sure!

Well, I have still a small problem…not all the actions can be seen, well right now, none is visible…

Am I missing smth still?

EDITED:

Well, I have made some alterations without using the code

object = bpy.context.object
object.animation_data.action = None

and if I do it manually, meaning I add the strips to the list and afterwards I push the “snowflake” and replace the latest (of each human) existing ones with the ones that I just made it works perfectly…


Here is the code (in order to show the queue of the actions) - this is the one with the problem


# Script for importing to nla
def to_nla(name, start_frame, end_frame):

 context = bpy.context
 object = context.object
 scene = context.scene
 scene.frame_end = scene.frame_end + 200
 frame = start_frame
 action = context.object.animation_data.action

 # add an NLA track

 newtrack = object.animation_data.nla_tracks.new()
 newtrack.name = name

 # add a new Strip at current frame 

 strip = newtrack.strips.new(name=action.name, start=start_frame, action=action)
 strip.name = action.name
 strip.action_frame_start = start_frame
 strip.frame_end = end_frame
 object = bpy.context.object
 object.animation_data.action = None

I think (going by memory without actually opening blender) that you just unlink the action from the strip using strip.unlink(action) or something like that.

Conversely (I think) you also can do a strip.add(action)… though IIRC that one takes a start frame too and either adds a new (sub?)strip or appends it to the end of the current one if it’ll fit.

I’m also pretty sure there’s a way to make an action editable (the snowflake) using python but don’t remember how.

This part of blender’s api is crazy confusing and could probably use a little more py-love…

Well, the thing is that I cannot find the right command to do that, the documentation does not help a lot…and now I can only see that are imported correctly but I cannot see the movements:(

I’m wondering if you have the wrong values for action_start_frame and action_end_frame on your strip. If your action has 20 frames and starts at frame 1 the values would be 1 and 20. The start_frame and end_frame are where you want it to be in the timeline. If you have start frame of 30 and end frame of 40 the action will be scaled to fit into 10 frames.

Having frames outside the extent of the action could explain why you don’t see anything.

That might be it…
so you say that if I have an action lasting 70 frames, I should write 1-70 (if I want to import it in the beginning).
Is there a way to add an action after the previous one is finished?, so I don’t have this problem.

Hit N on the NLA editor and bring up the properties. Select one strip. On the panels note the difference between active strip and action clip. Generally you would have


strip.action_start_frame = action.frame_range[0]
strip.action_end_frame = action.frame_range[1]

These are set for you by default.

if you have 3 actions a, b, and c and start at x, b would start at x + a.frame_range.length etc if you want to head tail them.

Hello,

I was working on this issue and some other that I had. I did it as you proposed


global count
count = 0
#Script for importing to nla
def to_nla(name, k):

    context = bpy.context
    object = context.object
    scene = context.scene
    global count
    if count == 0:
        start_frame = 1 
    else:
        count += 1
        start_frame = count 
                
    action = context.object.animation_data.action

    # add an NLA track

    newtrack = object.animation_data.nla_tracks.new()
    newtrack.name = name

    # add a new Strip at current frame 

    strip = newtrack.strips.new(name=action.name, start=start_frame, action=action)
    strip.name = action.name
    #strip.action_frame_start = start_frame
    # These are set for you by default
    #strip.action_frame_start = action.frame_range[0]
    #strip.action_frame_end = action.frame_range[1]
    
    # For actions and the second interaction
    if k == 0: 
        count = count + action.frame_range.length + 2
        scene.frame_end = scene.frame_end + count
    #    strip.action_frame_end = count
    #    strip.frame_end = count
    # For interactions  
    elif k == 1:  
        count = count      
    #    count = count + action.frame_range.length
    #    strip.frame_end = count
    #    strip.action_frame_end = count
    #    count = count - action.frame_range.length

    object = bpy.context.object
    object.animation_data.action = None

and although all the strips are added perfectly, I cannot see the first movements of the persons, if there is a second move of the same person, as shown on the picture…

Is there a way to make all the strips active? Or am I doing smth wrong (again)

Really thank you for the time and the effort:)

Really confused as to what you want here. If you want first and second human to play 13_14 at the same time then move the strip. The head / tail posted previously was for strips on the same rig. You seem to have set it up that way for each rig.

What I want is to play all the strips in the order that is appeared in the picture. But unfortunately, these two that I marked are not visible.

Is there anything else that I should be looking for, in order to make this work…or should I consider it as problem of blender??

From you image your strips look ok. Without a sample file, or more information in the image like the track / strip properties nothing jumps to mind. My suggestion is put it together manually, then if that works it will give you a reference.

The strange thing is that if I move a clip, lets say the first clip, and then place it again in the same spot, then it moves smoothly without any problems…I have made my script so simple that it doesn’t seem anything to go wrong.

Well, I should explain that my script is using absolute paths, which I try to make relative(without much success).
https://rapidshare.com/#!download|693p7|1482467213|sample.blend|7523

Here is a sample. Because it was 7.5MB I had to upload it rapidshara

Any thoughts? No? :frowning:

Your file has linked proxies, which aren’t included so it’s a bit hard to see what’s going on, protected layers etc. Linking is not my strong suite (lazy appender) I have an inkling that in this case that is where your issue is.

Hello again,

I am not sure what you mean exactly. I thought by linking the files would be visible, but I guess no…All the files that I use in my blend file are appended (linked is more or less the same, right?).
Should be looking the problem in the process of linking?

But, the thing is that if I do it manually (after using a script to linking all of my humanoids), there is no problem.

I suspect that there a problem with how I use snowflake…or maybe again the frames of each .bvh video, but I can’t tell for sure.

Could I tell you smth more, in order to advice me?