From: "TIM THIESSEN" Received: from resqmta-po-02v.sys.comcast.net ([96.114.154.161] verified) by media-motion.tv (CommuniGate Pro SMTP 6.1.0) with ESMTPS id 6446635 for ae-list@media-motion.tv; Mon, 07 May 2018 02:49:41 +0200 Received: from resomta-po-11v.sys.comcast.net ([96.114.154.235]) by resqmta-po-02v.sys.comcast.net with ESMTP id FUCJfLn89eCyfFURTfwyLb; Mon, 07 May 2018 00:55:51 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=comcast.net; s=q20161114; t=1525654551; bh=xvAL/A5Q7hIlaAqjRKheVAHtssgmTda49BEBlmvSeRU=; h=Received:Received:Date:From:Reply-To:To:Message-ID:Subject: MIME-Version:Content-Type; b=ZX+yWJ+qUCUqvYWhMK2Z39aNlx7fCGCZ8TqxnKq9WgrjXMS/IULtunKbWgyusBjuP 4CNDQGUEL7q/rsTSvqKCOlyZyem6UaNckPY64ui1Sql1YyDVLCKfnV1RyEWc8SENOq +hu1i3je/Tzx/drZ5GNDIHSpss0QTrlmESr6ioswMBFrUDKp+V6hBRYbJrlnrOKTa7 A/3K2/xrlAtZfsLBWx8F5+i6F3XD+cQRnnM6oNqtF2nB14QzTXHi3syRI2NC6c3lRZ 3fLXqCGaQha8AsBjmu7hwCEAcESpIlFgn91bGlR4SQ0xxxaAz20wVaiyTcfgr7il5L HJuqDZTY7jnbA== Received: from oxapp-hoc-48o.email.comcast.net ([96.118.241.125]) by resomta-po-11v.sys.comcast.net with ESMTPS id FURTfCHBf7DyHFURTf5G3d; Mon, 07 May 2018 00:55:51 +0000 Date: Sun, 6 May 2018 17:55:51 -0700 (PDT) Reply-To: TIM THIESSEN To: After Effects Mail List Message-ID: <1455428762.1095010.1525654551383@connect.xfinity.com> In-Reply-To: References: Subject: Re: [AE] scripting help - applying a preset only once MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_1095009_58595624.1525654551374" X-Priority: 3 Importance: Medium X-Mailer: Open-Xchange Mailer v7.8.4-Rev12 X-Originating-IP: ::ffff:24.21.84.163 X-Originating-Client: open-xchange-appsuite X-CMAE-Envelope: MS4wfHlCWIyPkow4NCULCRt4tGbJ8Psr5ou6R+OcLyZeAflVZMbr7fewd0RSu9JuWMK12hKkxLEJYy66jsMyfFZ4jWS3UgdKS4QkRoXcc7zgDlTgDSkl2XGz IMkf52E6mqvRMIzQR9bOKkidlV1Ql7/dJarL6fchdrLst87kWrONvkw8E3B8kNwFe6DJ78iQA1ts8TiBPtOSidVTaavECdewlO4= ------=_Part_1095009_58595624.1525654551374 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable I may have found my solution in David Torno's Free Function Friday - episod= e 1 covers getting Layer Effects - that may be part of the ticket - David T= orno's series on extendscript along with Mathias M=C3=B6hl'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 wrote: >=20 >=20 > ah that makes more sense >=20 >=20 > thanks >=20 > > > On May 6, 2018 at 2:35 PM Lloyd Alvarez wrote: > >=20 > > That was meant to say "not something you can check for" > >=20 > > On Sun, May 6, 2018 at 5:32 PM Lloyd Alvarez wrote: > >=20 > > > > > Hi Tim > > >=20 > > > The preset is but something you can check for. You need t= o check for what the preset applies whether is keyframes or expressions you= would check if that exists.=20 > > >=20 > > > Lloyd > > >=20 > > > On Sun, May 6, 2018 at 5:16 PM TIM THIESSEN wrote: > > >=20 > > > > > > >=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 expressions are only going to look = at the first one. I'm using the try-catch method to check that the effect i= s 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 pr= operties. 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: > > > >=20 > > > >=20 > > > > if(BOUNCrType =3D=3D "Position"){ > > > > if(positionFFX.exists =3D=3D 0){ //this check to se= e if the preset exists > > > > positionFFX =3D getFFXfile("BOUNCr_position.ffx", "= (BOUNCr_assets)", BOUNCr_position_ffx); > > > > } > > > > for (var i =3D 0; i < numSelected; i++){ > > > > try{ > > > > selLayers[i].property("Effects").property("BOUNCr_P= osition").value !=3D null; //I tried the =3D=3D 1 but AE kept throwing an e= rror > > > > }catch(err){ > > > > selLayers[i].applyPreset(positionFFX); //this appli= es the preset to the layer if and only if it doesn't exist > > > > } > > > > if(selLayers[i].property("Transform").property("Pos= ition").dimensionsSeparated){ > > > > selLayers[i].property("Transform").property("X Posi= tion").expression =3D posExpress; > > > > selLayers[i].property("Transform").property("Y Posi= tion").expression =3D posExpress; > > > > if(selLayers[i].threeDLayer){ > > > > selLayers[i].property("Transform").property("Z Posi= tion").expression =3D posExpress; > > > > } > > > > }else{ > > > > selLayers[i].property("Transform").property("Positi= on").expression =3D posExpress; > > > > } > > > > } > > > > } > > > >=20 > > > >=20 > > > > 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 th= en deselecting them (I don't know if that is possible - maybe throwing an a= lert is going to be the only solution) Any thoughts - this one is got me pi= ckled, I wish there was an .exists properties for effects. > > > >=20 > > > >=20 > > > > Thanks, > > > >=20 > > > > Tim T > > > >=20 > > > > > > > -- > > > Cheers, Lloyd > > >=20 > > > > > -- > > Cheers, Lloyd > >=20 > > >=20 ------=_Part_1095009_58595624.1525654551374 MIME-Version: 1.0 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable

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


Thanks

Tim T

<= blockquote type=3D"cite">On May 6, 2018 at 2:47 PM TIM THIESSEN <AE-Lis= t@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 ch= eck 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 expre= ssions 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 - becau= se no matter how many times the preset to the layer the expressions are onl= y going to look at the first one. I'm using the try-catch method to che= ck 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 i= t 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 co= de is:


if(BOUNCrType =3D=3D "Position"){
if(positionFFX.exist= s =3D=3D 0){ //this check to see if th= e preset exists
positionFFX =3D getFFXfile("BOUNCr_position.= ffx", "(BOUNCr_assets)", BOUNCr_position_ffx);
}
for (v= ar i =3D 0; i < numSelected; i++){
try{
selLayers[i].property(&= #34;Effects").property("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(= 4;Transform").property("Position").dimensionsSeparated){
se= lLayers[i].property("Transform").property("X Position").exp= ression =3D posExpress;
selLayers[i].property("Transform").prop= erty("Y Position").expression =3D posExpress;
if(selLayers[i].t= hreeDLayer){
selLayers[i].property("Transform").property("Z= Position").expression =3D posExpress;
}
}else{
selLayers[i= ].property("Transform").property("Position").expression =3D= posExpress;
}
}
}


=

sorry for the formatting the funny thing t= his more for almost every instance, it just fails when you have multiple pr= operties selected it instantly adds multiple instances of the preset. I'= ;m trying to think of a solution, like checking to see if properties are se= lected and then deselecting them (I don't know if that is possible - ma= ybe 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
--
Che= ers, Lloyd
=20 ------=_Part_1095009_58595624.1525654551374--