How to get NLA data from blend-file.

Hello.
I’m using blender sources and embedded player in my application. Now I want to read NLA data: strip’s start and end frames. I’m using this code:


void GPG_Application::printNlaInfo()
{
    GameObjectsStorage objects; // just a vector.
    GPG_Application::getGameObjects(&objects); // my custom function for receiving Game Objects.

    const int objectsCount = objects.size();
    for (int objectIndex = 0; objectIndex < objectsCount; objectIndex++)
    {
        KX_GameObject* obj = (KX_GameObject*) objects.at(objectIndex);

        AnimData* objAnimData = BKE_animdata_from_id(&obj->GetBlenderObject()->id);
        if (objAnimData == NULL) {
            obj->Release();
            continue;
        }

        ListBase nla_tracks = objAnimData->nla_tracks;
        NlaTrack* nlt;

        for (nlt = (NlaTrack*) nla_tracks.first; nlt; nlt = nlt->next) {
            std::cout << "NLA track. Name: " << nlt->name << std::endl;
            ListBase strips = nlt->strips;
            bActionStrip* strip;
            for (strip = (bActionStrip*) strips.first; strip; strip = strip->next) {
                std::cout << "Strip start: " << strip->start << std::endl;
                std::cout << "Strip end: " << strip->end << std::endl;

                std::cout << "Action name: " << (strip->act->id.name + 2) << std::endl;
                std::cout << "Action start: " << strip->actstart << std::endl;
                std::cout << "Action end: " << strip->actend << std::endl;
            }
        }

        obj->Release();
    }
}

But actions and strips start and end time always 0.
Please, help me. How to get NLA data from blend-file?

bActionStrip is the “old” version. NlaStrip is the one you want :slight_smile:

Oh, thanks, mate! :cool: