From: "TIM THIESSEN" Received: from resqmta-po-11v.sys.comcast.net ([96.114.154.170] verified) by media-motion.tv (CommuniGate Pro SMTP 6.1.0) with ESMTPS id 6446590 for ae-list@media-motion.tv; Sun, 06 May 2018 23:39:33 +0200 Received: from resomta-po-08v.sys.comcast.net ([96.114.154.232]) by resqmta-po-11v.sys.comcast.net with ESMTP id FRSRfUUXcJA8JFRTUfJT0A; Sun, 06 May 2018 21:45:44 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=comcast.net; s=q20161114; t=1525643144; bh=3jyLDVgTGAGy3nITnZfc3MJ7IW+s3l+cj54o8B2holU=; h=Received:Received:Date:From:Reply-To:To:Message-ID:Subject: MIME-Version:Content-Type; b=jGdp6Lj+B6i63WiWTj24G12T1gKGtUn2IicFnjPU2gpnDb0k2ioYgdTgNIzWBoFxN nj5+X4ui/uf3kJ+MqFgTEg9SRK5rqBBfWK+x9j4LHbYYaQiE7NjcshJqnA2+aKFLty j/qd1m7mFwwe/ony2VdHy/2y1kgAxOtVwbJQZm8C4+Zy8IKzYRKD5F000hyB0DEuGL K9JagoqAXB0x7g6CY9xgHVs0RvK3PjNNvQgsXsxlM4gjY6ciYmj+Zu1IJqU+zWlfl1 2SpcMp6Mmh3NiMS77aFl/a83QheYro18VO47KUqJ4DXF4xrvFSta0PTf1nLOAH8YGo wpG3T2YQIuZtg== Received: from oxapp-hoc-48o.email.comcast.net ([96.118.241.125]) by resomta-po-08v.sys.comcast.net with ESMTPS id FRTTfGTY9Ygm8FRTUfKgXW; Sun, 06 May 2018 21:45:44 +0000 Date: Sun, 6 May 2018 14:45:43 -0700 (PDT) Reply-To: TIM THIESSEN To: After Effects Mail List Message-ID: <1146654816.1092493.1525643143802@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_1092492_270972699.1525643143797" 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: MS4wfM4/Ef55UUl+PUOXh9md8bekvGNtE44Ob+7ABBBPWz8QzW8w4gQpVfDRVALz0U2RL+E0L872e02fUZWc+BP6jasSw0s1rLGRcLcIcKmT7ft3Jsh5O+/S FR9J21neTgM3eyOlpTVns1Z5udJZakef6gkOKVM0j4eubRkIUIBfJ4jNi/YQ82fHyRdFvlsU2xOe98LW9/9ixIOnABqUoiVt+pE= ------=_Part_1092492_270972699.1525643143797 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit 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 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 > ------=_Part_1092492_270972699.1525643143797 MIME-Version: 1.0 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable

the preset only applies an pseudo effect= , it is a controller for the expression, it doesn't apply the expressio= n - the expression does a try/catch to if the pseudo effect is there, and f= or 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 pseu= do effect it will not apply the preset, however if you have three prop= erties 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&#= 62; 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 expressio= ns you would check if that exists. 

<= div dir=3D"auto">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 pr= operty (position for example) and a preset to that layer - I only want to h= ave that preset applied once and only once - because no matter how many tim= es the preset to the layer the expressions are only going to look at the fi= rst one. I'm using the try-catch method to check that the effect is app= lied and if it that throws an error it will apply the preset. And for the m= ost part it works great, the one time it breaks is if you have several prop= erties 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:


if(BOUNCrTy= pe =3D=3D "Position"){
if(positionFFX.exists =3D=3D 0){ //this check to see if the preset exists
positionFFX =3D getFFXfile("BOUNCr_position.ffx", "(BOUN= Cr_assets)", BOUNCr_position_ffx);
}
for (var i =3D 0; i < = numSelected; i++){
try{
selLayers[i].property("Effects").pr= operty("BOUNCr_Position").value !=3D null; //I tried the =3D=3D 1 but AE kept throwing an error
}ca= tch(err){
selLayers[i].applyPreset(positionFFX); //this applies the preset to the layer if and only if it doesn= 9;t exist
}
if(selLayers[i].property("Transform").pr= operty("Position").dimensionsSeparated){
selLayers[i].property(= "Transform").property("X Position").expression =3D posExpre= ss;
selLayers[i].property("Transform").property("Y Position= ").expression =3D posExpress;
if(selLayers[i].threeDLayer){
sel= Layers[i].property("Transform").property("Z Position").expr= ession =3D posExpress;
}
}else{
selLayers[i].property("Tran= sform").property("Position").expression =3D posExpress;
} }
}


sorry for the formatting the funny thing this more for almo= st every instance, it just fails when you have multiple properties selected= it instantly adds multiple instances of the preset. I'm trying to thin= k of a solution, like checking to see if properties are selected and then d= eselecting 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.


Thanks,

=

Tim= T

--
Cheers, Lloyd
=20 ------=_Part_1092492_270972699.1525643143797--