MFnAnimCurve.getTangent signature change from 2017 to 2018

MFnAnimCurve.getTangent signature change from 2017 to 2018

Anonymous
Not applicable
795 Views
2 Replies
Message 1 of 3

MFnAnimCurve.getTangent signature change from 2017 to 2018

Anonymous
Not applicable

Hey all,

 

So, apparently the function signature for Snippet

MFnAnimCurve.getTangent(

has changed from float to double.

Thus breaking a number of methods I've been working on. I'd rather not have to regenerate new projects for these methods, specific to 2018.  Is there a recommended work-around for this?

0 Likes
Accepted solutions (1)
796 Views
2 Replies
Replies (2)
Message 2 of 3

cheng_xi_li
Autodesk Support
Autodesk Support
Accepted solution

Hi,

 

Are you using .Net? If you would like to fix the compiling errors without modifying original code, you could try extension methods.

 

e.g.

using Autodesk.Maya.OpenMaya;
using Autodesk.Maya.OpenMayaAnim;

//Enable it if it is compiling for Maya 2018
using MFnAnimCurveExtension;

namespace MFnAnimCurveTest
{
    public class CompilerTest
    {
        public void doIt(MObject obj)
        {
            float x = 0;
            float y = 0;
            var fn = new MFnAnimCurve(obj);
            fn.getTangent(0, ref x, ref y, true);
        }
    }
}

namespace MFnAnimCurveExtension
{
    public static class MFnAnimCurveExtension
    {
        public static void getTangent(this MFnAnimCurve curve, uint index, ref float x, ref float y, bool inTangent)
        {
            double _x = 0;
            double _y = 0;
            curve.getTangent(index, ref _x, ref _y, inTangent);
            x = (float)_x;
            y = (float)_y;
        }
    }
}

Hope it helps.

 

Yours,

Li

Message 3 of 3

Anonymous
Not applicable

I think I'm good with this.

 

Feels a lot cleaner than going about building out a bunch of #if/#else/#endif cases.

I'll give it a go, and accept the solution if it works for me.

0 Likes