INode is not defined, so I used IINode instead.
.Handle is not property of setXFormPacket. so I used .NativePointer instead
Yes, it will be compiled this way, But it will crash the Max again.
private readonly static IGlobal globalInterface = GlobalInterface.Instance;
private readonly static IInterface coreInterface = globalInterface.COREInterface;
public static unsafe void Test(IMatrix3 matrix, IINode node)
{
int time = coreInterface.Time;
ISetXFormPacket setXFormPacket = globalInterface.SetXFormPacket.Create(matrix, globalInterface.Matrix3.Create());
void* nativePtr = setXFormPacket.NativePointer.ToPointer();
IntPtr* ptr = (IntPtr*)nativePtr;
node.TMController.SetValue(coreInterface.Time, *ptr, true, GetSetMethod.Absolute);
globalInterface.COREInterface.RedrawViews(time, RedrawFlags.Normal, null);
}
private void Button_Click(object sender, RoutedEventArgs e)
{
IINode selNode = coreInterface.GetSelNode(0);
if (selNode == null) MessageBox.Show("Selection empty.");
else
{
IMatrix3 matrix = globalInterface.Matrix3.Create(true);
Test(matrix, selNode);
}
}