SDK-C# Set transform controller value


#1

I’m trying to set value for a node’s transform controller, but not working:

using Autodesk.Max;
using System.Windows;

namespace TestLibrary
{
    public partial class TestWindow : Window
    {
        private readonly static IGlobal globalInterface = GlobalInterface.Instance;
        private readonly static IInterface coreInterface = globalInterface.COREInterface;

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            int time = coreInterface.Time;
            IINode selNode = coreInterface.GetSelNode(0);
            if (selNode == null) MessageBox.Show("Selection empty.");
            else
            {
                IMatrix3 matrix = globalInterface.Matrix3.Create(true);
                selNode.TMController.SetValue(time,matrix,true,GetSetMethod.Absolute);
                globalInterface.COREInterface.RedrawViews(time, RedrawFlags.Normal, null);
            }
        }

        public TestWindow()
        {
            InitializeComponent();
        }
    }
}

What is wrong in my code?


#2

have you tried…

selNode.SetNodeTM(time, matrix);

?

otherwise you need to know what controller you are going to be dealing with usually a PRS so you have to deal with the sub controllers e.g.

Control *c;
c = node->GetTMController()->GetPositionController();

I think the setvalue above would only work if you were using a dedicated tm controller


#3

I want to save and load a pose for the entire rig, it may be biped or cat or max bones. SetNodeTM works globally, I need the local one. I’m just wondering why SetValue for the transform controller doesn’t work.


#4

try the c# version of this…

SetXFormPacket pckt(destTM);
tmControl->SetValue(ip->GetTime(), &pckt);