← All ideas
  • Published 12 Nov 2019

Context-specific NLA data sorely lacking in the Python API

It is currently very difficult to try and manipulate context-specific NLA tracks/strips with the Python API, making any kind of NLA-speciifc add-ons/operators too difficult for most to try and implement.

Basically, if you want to know which NLA Strips you've got selected in the NLA Editor, there is no simple context.selected_nla_strips, or anything like it.

This might seem pretty low down on the list of priorities, but all I can say is it's a nightmare if you ever run into this problem.

In the current API, if you want to list the visible strips within the NLA Editor in python you have to do a lot of work...

  1. First you have to search the Blend data for every type that references AnimData and uses NLA: Armature, CacheFile, Camera, Curve, FreestyleLineStyle, GreasePencil, Key, Lattice, Light, LightProbe, Mask, Material, Mesh, MetaBall, MovieClip, NodeTree, Object, ParticleSettings, Scene, Speaker, Texture & World.

  2. Then you have to determine the AnimDatas referenced in some way to the current scene and filter out the rest. This is particularly difficult when you consider the recursive nature of some of these references.

For instance, an object may use a Wave modifier. This modifier may reference a Texture. This Texture's AnimData may be using NLA, with several tracks and strips... If so it'll will be presented in the NLA Editor (assuming no filters are applied). To find all these references requires a deep understanding of the API.

  1. Then you have to filter the results according to the space's dopesheet filtering options (text, collections, type, hidden & selected):

Image

Like I said, to replicate the same results as the GUI you have to do a lot of work.

Even so I've written a very verbose script that achieves this for my personal needs but it's certainly not perfect as I'm often fixing inconsistencies between my results and Blender's internal filtering system.

To make life easier for me (and hopefully others who have run into the same problem), just as we have multiple context properties for fcurves when handling a dopesheet, I suggest we also have the equivalent for showing selected/active NLA Strips and Tracks in the NLA Editor context.

This should be easy to implement as the NLA Editor already has this functionality for display puproses. It's just a matter of making some of this backend-data visible via the bpy.context property.

100%

Development Status: Open

Upvote 8 Downvote 0
hedgehog90.tw
12 Nov 2019

0 Comments