Search code examples
c++animationmaya

Maya c++ API MFnCharacter createBlend always fails


I am trying to create a scene using animation clip that require two clips be blended. Everything I have tried has failed to create the blend this is the current state of my code.

Both instancedClip and previousClip are valid animation clip that are instanced and show up in the Trac editor.

        MObject curve = fnCurve.create(MFnAnimCurve::AnimCurveType::kAnimCurveTU, &mod);
        bool good = curve.isNull();
        MStatus s;
        //s = fnCurve.addKeyframe(MTime(0.0,MTime::uiUnit()),0.0);
        //s = fnCurve.addKeyframe(MTime(1.0,MTime::uiUnit()),1.0);

        bool c1 = previousClip.isNull();
        bool c2 = instancedClip.isNull();

        bool same = previousClip == instancedClip;

        MObject blend = character.createBlend(previousClip, instancedClip, curve, mod, &s);

Do you know why this the call to createBlend Fails? Does anyone know of an example or tutorial for blending animation clips using the c++ api?

I am trying to do this in a import file function.

I tried move the logic into a command that call after the scene has been imported and it works.

Does anyone know if there is something that need to be refreshed or connected before creating blends?


Solution

  • I was able to get the call for succeed after putting the same code into a callback using

    MTimerMessage::addTimerCallback