Mailing List AE-List@media-motion.tv ? Message #64034
From: TIM THIESSEN <AE-List@media-motion.tv>
Subject: Re: [AE] scripting help - applying a preset only once
Date: Sun, 6 May 2018 14:45:43 -0700 (PDT)
To: After Effects Mail List <AE-List@media-motion.tv>

the preset only applies an pseudo effect, it is a controller for the expression, it doesn't apply the expression - the expression does a try/catch to if the pseudo effect is there, and for the most part the try/catch here works. If you don't have any pseudo effect applied to the layer it will apply the preset if you do have a pseudo effect it will not apply the preset, however if you have three properties selected and run the script it will apply the preset three times and there will be three controllers applied to the layer.


tim t

On May 6, 2018 at 2:31 PM Lloyd Alvarez <AE-List@media-motion.tv> wrote:

Hi Tim

The preset is but something you can check for. You need to check for what the preset applies whether is keyframes or expressions you would check if that exists. 

Lloyd

On Sun, May 6, 2018 at 5:16 PM TIM THIESSEN <AE-List@media-motion.tv> wrote:

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

--
Cheers, Lloyd
 
Subscribe (FEED) Subscribe (DIGEST) Subscribe (INDEX) Unsubscribe Mail to ListMaster