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()) 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]
|