Quantcast
Channel: Daz Script Developer Discussion - Daz 3D Forums
Viewing all articles
Browse latest Browse all 1038

Slice of Array of Objects

$
0
0

Trying to rearrange the selected nodes in a scene and group them by the number tagged at the end of the label. Also trying to do this without having to loop thru those selected nodes too many times. So I build a sparce array:

var aSelectedNodes = new Array(nSelectedNodes);

With my current test data that wil set it to 30 items, but the loop will only fill it with six objects that have four nodes each. 

While trying to get rid of most of the empty array I don't need, I did this, sliced out the non-empty items in the array:

  var aGroups = aSelectedNodes.slice(0,nTrueLength);

  print("aGroups.length ["+aGroups.length+"]");

I got a length back, so a thing happened, if not quite what I want. Because the objects inside the array don't seem entirely defined anymore; I get an error trying to access one of the objects inside the array.

Script Error: Line 149

TypeError: Result of expression 'aGroups[ndx]' [undefined] is not an object.
Stack Trace: ()@D:/OneDrive/3D Content/MyDazNav/Scripts/Gollor/Expand Adamasen Level.dsa:149
149: aGroups[ndx].oFrontzone.oOldPos = aGroups[ndx].oFrontzone.oNode.getWSPos();

If I understand the error it's saying that either the object inside the array item got borked, or one of the subobjects of that object got borked. 

So I'm wondering what should I expect the slice function to do when it's working with an array of objects of objects of objects?

 


Viewing all articles
Browse latest Browse all 1038

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>