IControl.GetValue woes.

 
 
 
Posted by:andylt1
Data created:20 July 2013

I'm playing about with the autodesk.max wrappers in c# and while i realize this is the max.net forums, the two seem pretty closely related.. so i'm hoping someone will be able to help me here... im getting no luck on TheArea :(

So I'm trying to loop the scene hierarchy, and get the values of all the animatable tracks each node. Essentially i want to store the current data of any animatable/subanim/controller/track...  So, in maxscript i can do something like this...

[CODE]
fn recurseSubAnims theSubAnim levelStr:"--" =(      -- loop to the number of sub animation tracks (.numsubs)   for subIndx = 1 to theSubAnim.numSubs do(        -- get a handle to the child sub anim at the index number.    local childSubAnim = getSubAnim theSubAnim subIndx        -- we'll just do some nice printing for now    print (levelStr + "> " + childSubAnim.name)        -- here's where i get stuck in the api    if childSubAnim.Controller != undefined then(     -- I WANT THIS VALUE !!!!!     print (levelStr + "> VALUE >> " + (childSubAnim.Controller.value as string))    )        -- call this function again, using childSubAnim now as the element to search for further child subanims    recurseSubAnims childSubAnim levelStr:(levelStr+"--")   )     )    -- kick off the recursion at the top level with a single selected node  recurseSubAnims (Sphere())
[/CODE]

Above im not querying keys, im simply asking 'what is my (controller) value now'

So using the C# below is a test.... just trying to get the x position of the node.. same philosophy applies, loop the scene nodes, loop the IAnimatable tree and get the values. Except I'm getting hard crashes when i attempt to use IControl.getValue()

[CODE]
  public void populateTree( IINode node ){                int sceneTime = Kernel.Interface.Time;                            // get a list of all selected nodes.              List<IINode> selectedNodes = MaxUtils.getSelectedNodes();                            // loop the selected nodes              for (int i = 0; i < selectedNodes.Count; i++)              {                  // variable to current Inode                  IINode maxNode = selectedNodes[i];                    // create a tree item                  TreeViewItem nodeTreeItem = new TreeViewItem();                  nodeTreeItem.Header = maxNode.Name;                  this.treeView_subAnims.Items.Add(nodeTreeItem);            //**********************************************************************************      // below i am only trying to get the position x value of a selected node...                        // get the matrix controller                  IControl tm = node.TMController;            // get the position controller instance..       // c# uses properties to replace pointers                  IControl pc = tm.PositionController;                        // create an interval      IInterval ivalid = Kernel.Global.Interval.Create();            // set it to now                  try                  {                      ivalid.SetInstant(sceneTime);                  }                  catch { }            // create a system object to hold the unkown value type                  object pXval = new object();                    try                  {                      //allways crashes max, with no debug info on what caused it..                      pc.XController.GetValue(sceneTime, ref pXval, ivalid, GetSetMethod.Relative);                                        }                  catch { }                }          }
[/CODE]

Can anyone help me on this? Maybe im approaching this all wrong. I have a sneaky suspicion the using an object reference or the IIValid in the getValue call is causing the issue... but nothing i've tried seems to work.

I've been banging on this for a while now and I'm no closer to an answer. Any advice would be gratly appreciated