Ok I have a script that applies an expression to a single property (position for example) and a preset to that layer - I only want to have that preset applied once and only once - because no matter how many times the preset to the layer the expressions are only going to look at the first one. I'm using the try-catch method to check that the effect is applied and if it that throws an error it will apply the preset. And for the most part it works great, the one time it breaks is if you have several properties selected - it applies the same amount of presets as selected properties. Ever other instance of using this script works - and since it is applying the expression to the position property it shouldn't matter if you have the properties selected or not. I'm not even checking if you do have any properties selected. The snippet of code is:
if(BOUNCrType == "Position"){
if(positionFFX.exists == 0){ //this check to see if the preset exists
positionFFX = getFFXfile("BOUNCr_position.ffx", "(BOUNCr_assets)", BOUNCr_position_ffx);
}
for (var i = 0; i < numSelected; i++){
try{
selLayers[i].property("Effects").property("BOUNCr_Position").value != null; //I tried the == 1 but AE kept throwing an error
}catch(err){
selLayers[i].applyPreset(positionFFX); //this applies the preset to the layer if and only if it doesn't exist
}
if(selLayers[i].property("Transform").property("Position").dimensionsSeparated){
selLayers[i].property("Transform").property("X Position").expression = posExpress;
selLayers[i].property("Transform").property("Y Position").expression = posExpress;
if(selLayers[i].threeDLayer){
selLayers[i].property("Transform").property("Z Position").expression = posExpress;
}
}else{
selLayers[i].property("Transform").property("Position").expression = posExpress;
}
}
}
sorry for the formatting the funny thing this more for almost every instance, it just fails when you have multiple properties selected it instantly adds multiple instances of the preset. I'm trying to think of a solution, like checking to see if properties are selected and then deselecting them (I don't know if that is possible - maybe throwing an alert is going to be the only solution) Any thoughts - this one is got me pickled, I wish there was an .exists properties for effects.
Thanks,
Tim T