Save Pose Preset script Question

DraagonStormDraagonStorm Posts: 748
edited December 1969 in Daz Script Developer Discussion

The documentation at Save Pose Preset shows setting up for nodes (xrotation, yrotation, zrotation), but what about Pose Controls? These values are not saved using this sample.

Comments

  • djigneodjigneo Posts: 283
    edited June 2015

    Strangely I was *just* playing with this.

    The DzFileIoSettings ends up wanting a list of the names of all Nodes and Properties underneath the node getting saved.

    What I did was replace the lines that create the "hard-coded" arrays of the nodes/properties to iterate all child nodes and store the node and property names.

    Basically:

    
    function createPropertiesArray(oNode) {
     // Construct an array of objects that define the nodes and properties to save
     var aNodeProperties = new Array;
     var aObjectNodes = oNode.getNodeChildren(true);
     aObjectNodes[aObjectNodes.length] = oNode;
     for (var iNodeNum = 0; iNodeNum < aObjectNodes.length; iNodeNum++) {
      var oCurNode = aObjectNodes[iNodeNum];
      var oSaveProperties = new Object;
      var aPropNames = new Array;
      for (var iPropNum = 0; iPropNum < oCurNode.getNumProperties(); iPropNum++) {
       var sPropName = oCurNode.getProperty(iPropNum).getName();    
       aPropNames[iPropNum] = sPropName;
      }
      oSaveProperties.nodeName = oCurNode.getName();
      oSaveProperties.propNames = aPropNames;
      aNodeProperties[iNodeNum] = oSaveProperties;
     }
     return aNodeProperties;
    }
    

    Then, alter the code that is setting the values in the settings file to refer the node names and properties just staged:

    
    // somewhere before
    aNames = createPropertiesArray(oNode);
    
    // Iterate over our node/properties array
    for(var i = 0; i < aNames.length; i += 1 ){
     // Extract the name of the node
     sNode = aNames[ i ].nodeName;
            // ....
            // Extract the array of property names for the node
     aPropNames = aNames[ i ].propNames;
    

    Hopefully this should put you on the right track. I'd appreciate you letting me know if you see any mistakes here.
    (I just wrote a script to save pose presets for every object in the scene.)

    Post edited by djigneo on
Sign In or Register to comment.