From: "Zack Lovatt" Received: from mail-oi0-f44.google.com ([209.85.218.44] verified) by media-motion.tv (CommuniGate Pro SMTP 6.1.0) with ESMTPS id 6445265 for AE-List@media-motion.tv; Fri, 04 May 2018 06:07:58 +0200 Received: by mail-oi0-f44.google.com with SMTP id y15-v6so18055041oia.13 for ; Thu, 03 May 2018 21:14:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zacklovatt-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=Dlj0DqGUrMn3nEYvBCzu31IkYl+zI2K8InXYutCGXMs=; b=wnlvg7IucXBwdH2hlbLHW27TfkHyOZITCX7P4wI9LmyjMBo3Evm6LmqpllnMBuBnqM VsDkmLCi5tRtq9JfEuTFFu9eAb0HrgulLOq0Ark4jm+gL3o/OUjipFdWXkm8DEHpneex 9X9wWmAxAAwDJpcJjqnc+iDCosgF5mTsp9u+O1qmwm2/wV31PwVEr8Lp4O8OsYYEjMe0 SgbznQ/goLRfpsPS+ypm11icVd7nXduvSB2gjU9RF8BMPQBqsNrOHFzB3jl6qOLAFmO2 pFjXkkBwpbHxJ6gxUHy+GpPpPXaDQSUz+FPFPJXDvRVGeenLdmRUGwoXwORb8wXoiQww qjnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=Dlj0DqGUrMn3nEYvBCzu31IkYl+zI2K8InXYutCGXMs=; b=tpVH8yiy/SsjHMXqd28z3wSuKRFiJiOGc+2j7C23Jd2oPaBmrOS7Y7rQQ4vzs0mMl0 5dglZMEAHSbJhNYipUScTehDYlhfexCeuMCpGkL6SXPr6Hru2H6q9HK4BrHFzIscRxan cA0qjnQce5xjg1xelsICihu/hLD2hK28rCraY/WHVD70Rg3omF2n3qFSSzMJ8at6He+b lTDx9wSIOTOMapBWVEyrmR+8UF0/yQVTeEUe8SjJ0WECBcuAG/g+fh/cQWDtBMjedXMN JI0mcdvFKVWCxTTonJ8Ue3IWJTPdUBvzHj2AiGAUNs76dOhQ03dbDqb/PZEmcBKZz6ph OJmQ== X-Gm-Message-State: ALKqPwejUUNk3RY6IR6QjCj0/eL9eo5NKqzmHvLU80wjLggg6bcdY/3E 1cQbEXAecdU+tHEJs3MAHe9O2VDM/J3uYuggMXxjOyYgGw== X-Google-Smtp-Source: AB8JxZq4dEuhXCXZHlLcapIh3JrTfL6WTuGl4koYOwGFihbTqOqetyjdnXrctVpgQuvCdyIsDzzTZaDhoO3veMgrtW0= X-Received: by 2002:aca:1003:: with SMTP id 3-v6mr1841760oiq.317.1525407243913; Thu, 03 May 2018 21:14:03 -0700 (PDT) MIME-Version: 1.0 Received: by 10.74.213.8 with HTTP; Thu, 3 May 2018 21:13:23 -0700 (PDT) X-Originating-IP: [45.49.154.120] In-Reply-To: References: Date: Thu, 3 May 2018 21:13:23 -0700 Message-ID: Subject: Re: [AE] scripting help - getting colour value To: After Effects Mail List Content-Type: multipart/alternative; boundary="000000000000e960e0056b598c54" --000000000000e960e0056b598c54 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Ah! Got it. The issue is that AE isn't updating fast enough between the time you add the expression and when you sample the property value. I found that by forcing the script to wait for a little bit (150ms seemed to be the sweet spot in my testing) it would catch it 100% of the time. Here's a revised onClick. Also cleans up some of the redundant logic (and you never declared 'g' or 'b', so they were global..) apply.onClick =3D function() { clearOutput(); var myComp =3D app.project.activeItem; var myLayer =3D myComp.selectedLayers[0]; app.beginUndoGroup("Extrapolated Zeugma"); myLayer.property("ADBE Effect Parade").addProperty("ADBE Fill"); myLayer.property("ADBE Effect Parade").addProperty("ADBE Color Link"); myLayer.property("ADBE Effect Parade").addProperty("ADBE Color Control"); var colorControl =3D myLayer.property("ADBE Effect Parade").property("ADB= E Color Control").property("ADBE Color Control-0001"); colorControl.expression =3D colourExpression; $.sleep(150); var controlValue =3D colorControl.value; var r =3D controlValue[0]; var g =3D controlValue[1]; var b =3D controlValue[2]; alert("RGB: " + r + "," + g + "," + b); app.endUndoGroup(); }; Zack Lovatt 424.442.0020 www.zacklovatt.com On Thu, May 3, 2018 at 8:13 PM, Chris Zwar wrote: > Thanks for your interest. Yes your script works fine, and it=E2=80=99s p= rompted > me to play around a bit more. My full script is a few hundred lines and = I > won=E2=80=99t post it all, but I have stripped it down to the basics and = I=E2=80=99ve found > where the problem comes from. > In my full script I am applying the Color Link effect and sampling the > colour after it is applied. It=E2=80=99s this effect which is not workin= g in CC > 2017 or CC 2018. As an experiment, I tried applying the basic fill effec= t > instead, and when I do that the script does work as expected. > > I=E2=80=99ve pasted a version of the script below. If you leave it as-is.= the > color link effect is applied and the sampleImage only returns 0. If you > comment out the color link effect to prevent it being added, then only th= e > fill effect is applied. Then the sampleImage correctly returns the value= s > of 1,0,0. > > I would love to know if you can replicate this behaviour - thanks again. > > -Chris > > { > function ZaksTest(thisObj) { > var ZaksTestData =3D new Object (); > ZaksTestData.strApply=3D"Apply"; > var colourExpression=3D"x=3DthisLayer.width/2;y=3DthisLayer.height/2;\n > c=3DsampleImage([x,y], radius =3D [2, 2], postEffect =3D true, t =3D time= );\n c"; > // Set up the GUI > function ZaksTest_buildUI(thisObj) { > var myPanel =3D (thisObj instanceof Panel) ? thisObj : new > Window ("palette","ZaksTest",undefined, {resizable:true}); > var res =3D > "group { \ > orientation:'column', > alignment:['fill','top'], \ > apply: Group { \ > alignment:['right','top'], \ > applyBtn: Button { text:'" + > ZaksTestData.strApply + "' }, \ > }, \ > }"; > myPanel.grp =3D myPanel.add(res) > var apply=3DmyPanel.grp.apply.applyBtn; > // Apply button - main part > apply.onClick=3Dfunction() > { > var myComp =3D app.project.activeItem; > app.beginUndoGroup("ZaksTest"); > clearOutput(); > var myLayer =3D myComp.selectedLayers[0]; > myLayer.property("ADBE Effect Parade").addProperty("ADBE Fill"); > // comment out the color link effect and the script works. If it's > enabled it doesn't // > myLayer.property("ADBE Effect Parade").addProperty("ADBE Color Link"); > myLayer.property("ADBE Effect Parade").addProperty("ADBE Color Control"); > myLayer.property("ADBE Effect Parade").property("ADBE Color > Control").property("ADBE Color Control-0001").expression=3DcolourExpressi= on; > var RGB=3D[1,1,1,1]; > var r=3D0;g=3D0;b=3D0; > RGB=3DmyLayer.property("ADBE Effect Parade").property("ADBE Color > Control")(1).value; > r=3DRGB[0]; > g=3DRGB[1]; > b=3DRGB[2]; > alert("RGB: "+r+","+g+","+b); > app.endUndoGroup(); > } > // Set panel resizing > myPanel.layout.layout (true); > myPanel.grp.minimumSize=3DmyPanel.grp.size; > myPanel.layout.resize(); > myPanel.onResizing =3D myPanel.onResize=3D function () {this.layout.resiz= e()} > return myPanel; > } > var ZaksTestPal =3D ZaksTest_buildUI(thisObj); > if ((ZaksTestPal !=3D null) && (ZaksTestPal instanceof Window)) > { > ZaksTestPal.center(); > ZaksTestPal.show(); > } > } > ZaksTest(this) ; > } > +---End of message---+ > To unsubscribe send any message to > --000000000000e960e0056b598c54 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Ah! Got it. The issue is that AE isn't updating fast e= nough between the time you add the expression and when you sample the prope= rty value. I found that by forcing the script to wait for a little bit (150= ms seemed to be the sweet spot in my testing) it would catch it 100% of the= time.

Here's a revised onClick. Also cleans up some= of the redundant logic (and you never declared 'g' or 'b',= so they were global..)

apply.onClick =3D function() {
=C2=A0 clearOutput();
=C2=A0 var myComp =3D app.project.activeItem;
=C2=A0 var myLayer =3D my= Comp.selectedLayers[0];
=C2=A0 app.begi= nUndoGroup("Extrapolated Zeugma");

=C2=A0 myLayer.property("ADBE Effect Parade").addProperty(&= quot;ADBE Fill");
=C2=A0 myLayer.property("ADBE Effect Parade").addProperty("= ADBE Color Link");

=C2=A0 var = colorControl =3D myLayer.property("ADBE Effect Parade").property(= "ADBE Color Control").property("ADBE Color Control-0001"= ;);
=C2=A0 colorContro= l.expression =3D colourExpression;

=C2= =A0 $.sleep(150);

=
=C2=A0 var controlVal= ue =3D colorControl.value;

=C2=A0 var r= =3D controlValue[0];
= =C2=A0 var g =3D controlValue[1];
=C2=A0 var b =3D controlValue[2];

=C2=A0 alert("RGB: " + r + "," + g + ",&q= uot; + b);

=
=C2=A0 app.endUndoGroup();
};

Zack Lovatt
424.442.0020

On Thu, May 3, 2018 at 8:13 PM, Chris Zwar <= span dir=3D"ltr"><AE-List@media-motion.tv> wrote:
Thanks for your interest.=C2=A0 Yes your script works fine, a= nd it=E2=80=99s prompted me to play around a bit more.=C2=A0 My full script= is a few hundred lines and I won=E2=80=99t post it all, but I have strippe= d it down to the basics and I=E2=80=99ve found where the problem comes from= .
In my full script I am applying the Color Link effect and sampling the colo= ur after it is applied.=C2=A0 It=E2=80=99s this effect which is not working= in CC 2017 or CC 2018.=C2=A0 As an experiment, I tried applying the basic = fill effect instead, and when I do that the script does work as expected.
I=E2=80=99ve pasted a version of the script below. If you leave it as-is. t= he color link effect is applied and the sampleImage only returns 0.=C2=A0 I= f you comment out the color link effect to prevent it being added, then onl= y the fill effect is applied.=C2=A0 Then the sampleImage correctly returns = the values of 1,0,0.

I would love to know if you can replicate this behaviour - thanks again.
-Chris

{
=C2=A0 =C2=A0 function ZaksTest(thisObj) {=C2=A0 =C2=A0 =C2=A0
var=C2=A0 =C2=A0ZaksTestData =3D new Object ();
=C2=A0 =C2=A0 =C2=A0 =C2=A0 ZaksTestData.strApply=3D"Apply";
var colourExpression=3D"x=3DthisLayer.width/2;y=3DthisLayer.heigh= t/2;\n c=3DsampleImage([x,y], radius =3D [2, 2], postEffect =3D true, = t =3D time);\n c";
// Set up the GUI=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0
=C2=A0 =C2=A0 =C2=A0 =C2=A0 function ZaksTest_buildUI(thisObj) {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 var myPanel =3D (thisObj instance= of Panel) ? thisObj : new Window ("palette","ZaksTest",= undefined, {resizable:true});
var res =3D
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 "group { \
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 orientat= ion:'column', alignment:['fill','top'], \
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 apply: Group { \
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 alignment:['right','top&= #39;], \
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 applyBtn: Button { text:'" = + ZaksTestData.strApply + "' }, \
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 }, \
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 }";=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0<= br> myPanel.grp =3D myPanel.add(res)
var apply=3DmyPanel.grp.apply.applyBtn;
// Apply button - main=C2=A0 part=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0
apply.onClick=3Dfunction()
{
var myComp =3D app.project.activeItem;
app.beginUndoGroup("ZaksTest");
clearOutput();
var myLayer =3D myComp.selectedLayers[0];
myLayer.property("ADBE Effect Parade").addProperty("ADBE Fil= l");
// comment out the color link effect and the script works.=C2=A0 If it'= s enabled it doesn't //
myLayer.property("ADBE Effect Parade").addProperty("ADBE Col= or Link");
myLayer.property("ADBE Effect Parade").addProperty("ADBE Col= or Control");
myLayer.property("ADBE Effect Parade").property("ADBE Color = Control").property("ADBE Color Control-0001").expression=3D<= wbr>colourExpression;
var RGB=3D[1,1,1,1];
var r=3D0;g=3D0;b=3D0;
RGB=3DmyLayer.property("ADBE Effect Parade").property("ADBE = Color Control")(1).value;
r=3DRGB[0];
g=3DRGB[1];
b=3DRGB[2];
alert("RGB: "+r+","+g+","+b);
app.endUndoGroup();
}
// Set panel resizing
myPanel.layout.layout (true);
myPanel.grp.minimumSize=3DmyPanel.grp.size;
myPanel.layout.resize();
myPanel.onResizing =3D myPanel.onResize=3D function () {this.layout.resize(= )}
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return myPanel;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 }
var ZaksTestPal =3D ZaksTest_buildUI(thisObj);=C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0
=C2=A0 =C2=A0 =C2=A0 =C2=A0 if ((ZaksTestPal !=3D null) && (ZaksTes= tPal instanceof Window))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ZaksTestPal.center();
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ZaksTestPal.show();
=C2=A0 =C2=A0 =C2=A0 =C2=A0 }
=C2=A0 =C2=A0 }
ZaksTest(this) ;
}
+---End of message---+
To unsubscribe send any message to <ae-list-off@media-motion.tv>

--000000000000e960e0056b598c54--