Loop through root elements in a scene - SOLVED

chris-2599934chris-2599934 Posts: 1,817

I'm trying to write a script that will loop through and change only those items within the scene which have no parents. I assumed that such items would be Nodes, and could be identified by checking the isRootNode property, but according to my script, everything is a root node:

I was expecting to see it list the cube and the sphere, but not the cone as it's parented to the cube. Where am I going wrong?

PS. Here's my script in plain text:

// DAZ Studio version 4.10.0.123 filetype DAZ Script
// Define an anonymous function;
// serves as our main loop,
// limits the scope of variables

(function(){

var aAllNodes = Scene.getNodeList();
var nAllNodes = aAllNodes.length;

var oNode;

// Iterate over the nodes
for( var i = 0; i < nAllNodes; i += 1 ){
   // Get the 'current' node
   oNode = aAllNodes[ i ];

   if (oNode.isRootNode) {
      print(oNode.objectName + " is a root node");
   }
}

// Finalize the function and invoke
})();

 

scriptshot.png
882 x 791 - 38K
Post edited by chris-2599934 on

Comments

  • rbtwhizrbtwhiz Posts: 2,250

    DzNode::isRootNode() is a function, not a property; you are missing the parenthesis.

    -Rob

Sign In or Register to comment.