Notifications
Clear all

[Closed] [C#] Get Key Type

 MZ1

We have different type of key for example IIBezPoint3Key,IIBezScaleKey,IIBezFloatKey,etc.
My question is if we have a controller keyframed inside max, how we can detect type of it’s keys?

6 Replies

I know class of controller. Every controller class needs its own type of keys. This’s all what you have.

 MZ1

How many variations we have in controllers and key types? Is this a good method? I’m not sure how I can handle rotation controller.

using Autodesk.Max;
using System;

namespace TestLibrary
{
    public static class TestClass
    {
        static IGlobal globalInterface = GlobalInterface.Instance;
        static IInterface coreInterface = globalInterface.COREInterface;

        public static void TestMethod(UIntPtr controllerHandle)
        {
            IControl control = (IControl)globalInterface.Animatable.GetAnimByHandle(controllerHandle);
            IClass_ID cID = control.ClassID;
            SClass_ID sID = control.SuperClassID;

            if (cID.PartA == (uint)BuiltInClassIDA.HYBRIDINTERP_POSITION_CLASS_ID ||
                cID.PartA == (uint)BuiltInClassIDA.HYBRIDINTERP_COLOR_CLASS_ID ||
                cID.PartA == (uint)BuiltInClassIDA.HYBRIDINTERP_POINT3_CLASS_ID)
            {
                IIBezPoint3Key key = globalInterface.IBezPoint3Key.Create();
            }
            else if (cID.PartA == (uint)BuiltInClassIDA.HYBRIDINTERP_SCALE_CLASS_ID)
            {
                IIBezScaleKey key = globalInterface.IBezScaleKey.Create();
            }
            else if (cID.PartA == (uint)BuiltInClassIDA.HYBRIDINTERP_FLOAT_CLASS_ID)
            {
                IIBezFloatKey key = globalInterface.IBezFloatKey.Create();
            }
            else if (cID.PartA == (uint)BuiltInClassIDA.LININTERP_POSITION_CLASS_ID)
            {
                IILinPoint3Key key = globalInterface.ILinPoint3Key.Create();
            }
            else if (cID.PartA == (uint)BuiltInClassIDA.LININTERP_SCALE_CLASS_ID)
            {
                IILinScaleKey key = globalInterface.ILinScaleKey.Create();
            }
            else if (cID.PartA == (uint)BuiltInClassIDA.LININTERP_FLOAT_CLASS_ID)
            {
                IILinFloatKey key = globalInterface.ILinFloatKey.Create();
            }
            else if (cID.PartA == (uint)BuiltInClassIDA.TCBINTERP_POSITION_CLASS_ID || cID.PartA == (uint)BuiltInClassIDA.TCBINTERP_POINT3_CLASS_ID)
            {
                IITCBPoint3Key key = globalInterface.ITCBPoint3Key.Create();
            }
            else if (cID.PartA == (uint)BuiltInClassIDA.TCBINTERP_FLOAT_CLASS_ID)
            {
                IITCBFloatKey key = globalInterface.ITCBFloatKey.Create();
            }
            else if (cID.PartA == (uint)BuiltInClassIDA.TCBINTERP_SCALE_CLASS_ID)
            {
                IITCBScaleKey key = globalInterface.ITCBScaleKey.Create();
            }
        }
    }
}

All looks very complicated and “long” by coding matter, but I don’t see another way.
And anyway you have to know for sure the type of key for a specified controller to its specific values(properties).

 MZ1

Do we have a function like MS function “GetPropNames” inside C#-C++? Maybe by using that we can filter out keys easier based on it’s properties.

how many types of controllers? 10, 20,30? what’s the problem? make a table once – control class -> key class

the question is – how to know a key class for a custom controls? nohow… we have to know it before try to do anything with it.

1 Reply
 MZ1
(@mz1)
Joined: 1 year ago

Posts: 0

Because my tool will be used in in-house production, I think we can skip this.