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

I may have found my solution in David Torno's Free Function Friday - episode 1 covers getting Layer Effects - that may be part of the ticket - David Torno's series on extendscript along with Mathias Möhl's class at FXPhd Along with Llyod's class there are my main sources for learning Javascript.


Thanks

Tim T

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

ah that makes more sense


thanks

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

That was meant to say "not something you can check for"

On Sun, May 6, 2018 at 5:32 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
--
Cheers, Lloyd
 
Subscribe (FEED) Subscribe (DIGEST) Subscribe (INDEX) Unsubscribe Mail to ListMaster