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 6446593 for AE-List@media-motion.tv; Sun, 06 May 2018 23:29:45 +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=CQOFg5b/EdkFKGLK9EFqbtKbC4Um/6r1874RrP1WfNY=; b=d6xuMNFstxfEKMrzkgFv0vYHa 1Hy21VdCJ8kPWOGNsn5E1L1mWKf4TGsLYkCm2oq6TCIGqp9ThSYIc9aaD2nH2a6IwKsX3IYhb9IZt g0UKnp6bKcmGBotVDKdzqnmxMzSQXSVs02nVK6yHLjNj6O+bzxvkXrT+QjN+V/hxE0zOkXQM1IsY3 s4sODldDUJy2+LB/AdiOdoTU48KU94KPDMoXxOM8vQHgoCoBfpECvfF2xwgrBruCnU+DvakFlfY9A zRtvbT0lNiXuuGO8vJV9tAnqEwAz84elYbq/VaP8TmtM3mtJ/p4JzGTDZwxLf/v/tWaQ2l1P8V81X KiPZU/SBw==; Received: from mail-ua0-f174.google.com ([209.85.217.174]) by aescriptsmhm.magemojo.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.90_1) (envelope-from ) id 1fFRK0-000Sej-O2 for AE-List@media-motion.tv; Sun, 06 May 2018 21:35:56 +0000 Received: by mail-ua0-f174.google.com with SMTP id i3so17171633uad.4 for ; Sun, 06 May 2018 14:35:56 -0700 (PDT) X-Gm-Message-State: ALQs6tC+Rpim8fOnvZY8q8LM94xiPrir1KGcFEfL8Um/bbfU0Uuht+uS sQV0RdSFcNrrp/Bym1FSws4dErjkgGYH4+DhXyk= X-Google-Smtp-Source: AB8JxZrD+rw+WlM/zcOSVtcUInudIJl/tu6ngo22A7je/lMjAWbqzgmjYqTlB/G4fJ6Oz75SPUMXBvFkRq7aZG1TwcM= X-Received: by 10.176.64.231 with SMTP id i94mr19309199uad.35.1525642551493; Sun, 06 May 2018 14:35:51 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Sun, 06 May 2018 21:35:41 +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="94eb2c1237dc560ea6056b905690" --94eb2c1237dc560ea6056b905690 Content-Type: text/plain; charset="UTF-8" That was meant to say "not something you can check for" On Sun, May 6, 2018 at 5:32 PM Lloyd Alvarez 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 > 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 --94eb2c1237dc560ea6056b905690 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
That was meant to say "not something you can check for"=

On Sun, May 6, 2018 at= 5:32 PM Lloyd Alvarez <AE-Li= st@media-motion.tv> wrote:
<= div>
Hi Tim

The preset is but something you can check for. You need to check for w= hat the preset applies whether is keyframes or expressions you would check = if that exists.=C2=A0

Ll= oyd

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

Ok I have a script that applies an expression to a single property (pos= ition for example) and a preset to that layer - I only want to have that pr= eset applied once and only once - because no matter how many times the pres= et to the layer the expressions are only going to look at the first one. I&= #39;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 sele= cted - it applies=C2=A0the same amount of presets as selected properties. E= ver other instance of using this script works - and since it is applying th= e expression to the position property it shouldn't matter if you have t= he properties selected or not. I'm not even checking if you do have any= properties selected. The snippet of code is:


if(BOUNCrType =3D=3D= "Position"){
if(positionFFX.exists =3D=3D 0){=C2=A0//this check to see if the preset exists positionFFX =3D getFFXfile("BOUNCr_position.ffx", "(BOUNC= r_assets)", BOUNCr_position_ffx);
}
for (var i =3D 0; i < n= umSelected; i++){
try{
selLayers[i].property("Effects").p= roperty("BOUNCr_Position").value !=3D null; //I tried the =3D=3D 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("Transfor= m").property("Position").dimensionsSeparated){
selLayers= [i].property("Transform").property("X Position").expres= sion =3D posExpress;
selLayers[i].property("Transform").prope= rty("Y Position").expression =3D posExpress;
if(selLayers[i].= threeDLayer){
selLayers[i].property("Transform").property(&qu= ot;Z Position").expression =3D posExpress;
}
}else{
selLay= ers[i].property("Transform").property("Position").expre= ssion =3D posExpress;
}
}
}


sorry for the formatting t= he funny thing this more for almost every instance, it just fails when you = have multiple properties selected it instantly adds multiple instances of t= he preset. I'm trying to think of a solution, like checking to see if p= roperties 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 propert= ies for effects.


Thanks,

Tim T

--
Cheers, Lloyd
--
Cheers, Lloyd
--94eb2c1237dc560ea6056b905690--