-
Loop Through Layer Controls and Retrieve Position/Rotation Values
Hello this is probably an easy fix but I can’t seem to get the syntax correct.
I need to loop through 10 layers which are set with layer expression controls, retrieve the position or rotation values of each layer and store those values in an array. I’m using a try/catch so it doesn’t throw an error if no layer is set.
All I need to do is increment the number in the effect name but I’m getting hung up on what seems like a simple bit of code. Also, is there a way to combine the two separate loops into a single loop?
targetLayers = new Array();
for (var i=0; i<10; i++){
myStr1 = 'effect("My Effect")("Target Layer ';
myStr2 = '")'
t = i+1;
try{
targetLayers[i] = myStr1+t+myStr2;
}catch (err){
targetLayers[i] = "";
}
}
var layerPos = new Array();
for (var i=0; i<10; i++){
try{
layerPos[i] = targetLayers[i].transform.position;
}catch (err){
layerPos[i] = [0,0,0];
}
}