From: "Lloyd Alvarez" Received: from aescripts.com ([162.252.107.88] verified) by media-motion.tv (CommuniGate Pro SMTP 6.1.0) with ESMTPS id 6446591 for AE-List@media-motion.tv; Sun, 06 May 2018 23:26:03 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=aescripts.com; s=dkim; h=Content-Type:To:Subject:Message-ID:Date:From: In-Reply-To:References:MIME-Version:Sender:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=7gk1QtlF9wAjwkBS+82gfkgNMV74gKrDUzJqkhi+bDM=; b=wlzDf8MpcbOxN5Vh9FBBhcuDl kNtcxFOE6+zv3gsk6z3+CQlHTtdUQ1S98T8gpC4Tu7sJD50HL4hyxCnm6io+U89ihDcEJBUMjEUBJ nrep5eIZjkDC8pMQMKeIwPsSO/hyyBK3z09pXY5URDo2fO0aduTcq8SDfl4hQx3BE6GvysrdlruaF dCS09z4D8YRqm6oAACS5BMYDXth6vIiiaeWop7OpyXTsjghlTAW4ymw3hXHGzqPWOxk5yKKsIQrPW HiS5vDvPOQdfzDEVeEbWoB3s06hXPsNO09OE+WV89stJZEQ9LZITC6O8usB9hpM7gGcrc8NchERh7 hymPAqung==; Received: from mail-vk0-f48.google.com ([209.85.213.48]) by aescriptsmhm.magemojo.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.90_1) (envelope-from ) id 1fFRGQ-000SVq-A0 for AE-List@media-motion.tv; Sun, 06 May 2018 21:32:14 +0000 Received: by mail-vk0-f48.google.com with SMTP id 10-v6so16297573vkh.5 for ; Sun, 06 May 2018 14:32:14 -0700 (PDT) X-Gm-Message-State: ALQs6tDEX5yl5xgzPwOd9+wsdFdQKg2g+9ayCZv2H3NWQWhYxL05s802 W/S/msffn/o5IPa+T1WCfdwZ5xRZMWPGzO21S54= X-Google-Smtp-Source: AB8JxZqoJ0ufIx4CHcxRXxq16o5Qd/ocqG+77eIGyv6HZE9pmXtgWsrEhn9e7c4gqUNGEWelQaWqj59hQ3ReOTQWQkg= X-Received: by 2002:a1f:8792:: with SMTP id j140-v6mr29809601vkd.109.1525642329050; Sun, 06 May 2018 14:32:09 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Sun, 06 May 2018 21:31:57 +0000 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [AE] scripting help - applying a preset only once To: After Effects Mail List Content-Type: multipart/alternative; boundary="00000000000013d69a056b90494d" --00000000000013d69a056b90494d Content-Type: text/plain; charset="UTF-8" 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 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 --00000000000013d69a056b90494d Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
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.=C2=A0

L= loyd

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

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 ex= pressions are only going to look at the first one. I'm using the try-ca= tch method to check that the effect is applied and if it that throws an err= or 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=C2= =A0the same amount of presets as selected properties. Ever other instance o= f using this script works - and since it is applying the expression to the = position property it shouldn't matter if you have the properties select= ed or not. I'm not even checking if you do have any properties selected= . The snippet of code is:


if(BOUNCr= Type =3D=3D "Position"){
if(positionFFX.exists =3D=3D 0){=C2= =A0//this check to see if the preset exi= sts
positionFFX =3D getFFXfile("BOUNCr_position.ffx", = "(BOUNCr_assets)", BOUNCr_position_ffx);
}
for (var i =3D= 0; i < numSelected; i++){
try{
selLayers[i].property("Effe= cts").property("BOUNCr_Position").value !=3D null; //I tried the =3D=3D 1 but AE kept throwing an er= ror
}catch(err){
selLayers[i].applyPreset(positionFFX); //this applies the preset to the layer if an= d only if it doesn't exist
}
if(selLayers[i].property(&q= uot;Transform").property("Position").dimensionsSeparated){ selLayers[i].property("Transform").property("X Position&q= uot;).expression =3D posExpress;
selLayers[i].property("Transform&= quot;).property("Y Position").expression =3D posExpress;
if(s= elLayers[i].threeDLayer){
selLayers[i].property("Transform").= property("Z Position").expression =3D posExpress;
}
}else= {
selLayers[i].property("Transform").property("Position&= quot;).expression =3D posExpress;
}
}
}


sorry for the formatting the funny thing this more for alm= ost every instance, it just fails when you have multiple properties selecte= d it instantly adds multiple instances of the preset. I'm trying to thi= nk 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 p= ickled, I wish there was an .exists properties for effects.


Thanks,

Tim T

--
Cheers, Lloyd
--00000000000013d69a056b90494d--