Mailing List AE-List@media-motion.tv — Message #64017
From: Zack Lovatt <AE-List@media-motion.tv>
Subject: Re: [AE] scripting help - getting colour value
Date: Thu, 3 May 2018 17:56:03 -0700
To: After Effects Mail List <AE-List@media-motion.tv>
Any chance you're doing something like not declaring variables, and so you're loading something into the global space? In that way if you don't close AE, run the script via File > Script and then Window > [Script.jsx], you'll already have initialized certain things.
Best bet would be to post / share the full script so somebody else can check it out!


Running this, based on your code above, yields the same working result regardless of whether it's run from File > Script or Window > Script.jsx


(function () {
  var comp = app.project.activeItem;
  var layer = comp.selectedLayers[0];

  layer.property("ADBE Effect Parade").addProperty("ADBE Color Control");

  var colourControl = layer.property("ADBE Effect Parade").property("ADBE Color Control").property("ADBE Color Control-0001");
  colourControl.expression="var x = thisLayer.width / 2;\nvar y = thisLayer.height / 2;\nsampleImage([x,y], radius = [2, 2], postEffect = true, t = time);";

  var rgbValue = colourControl.value;
  alert(rgbValue);
})();





Zack Lovatt
424.442.0020

On Thu, May 3, 2018 at 4:29 PM, Chris Zwar <AE-List@media-motion.tv> wrote:
I should have tried this earlier, but I tested the script on older versions of AE.  It works fine in CS6, CC 2014 and I’m downloading CC2015 again to try it there.  It doesn’t work in CC 2017 or 2018 so I’m going to assume it’s some sort of bug.

FWIW I’ve noticed that other 3rd party scripts which do the same thing I’m doing also don’t work in CC 2018.

Time to file a bug report...

-Chris


On 3 May 2018, at 11:00 am, Zack Lovatt <AE-List@media-motion.tv> wrote:

Can you post the full script?

Zack Lovatt
424.442.0020

On Wed, May 2, 2018 at 5:51 PM, Chris Zwar <AE-List@media-motion.tv> wrote:
I’ll have a look at using a variable but it’s simpler if I don’t have to. 

The thing that stumps me is that the script works if run from the scripts menu, it just doesn’t work when opened from the windows menu.

I had a quick play yesterday and I changed the .value to .valueAtTime(time, false).  The “false” flag is supposed to force the return of the expression and not the underlying pre-expression value.  It still doesn’t work.  The colour control that is applied by the script works as expected after the script has run, so there’s no issue with the script applying the effect and the expression.

I’ll try using a slider instead but I appreciate any other suggestions...

> On 3 May 2018, at 7:09 am, TIM THIESSEN <AE-List@media-motion.tv> wrote:
>
> I'm thinking the problem is you are applying an expression to the controller and then asking the value of the controller - the problem is that if you apply an expression to say position and then ask the for the value it returns the default position. rather than add the expression to sample the color just create a variable to sample the point you need and then it will return the correct color. I don't know your whole application so that may not be possible, and the last time I tried sampleImage() I had some weird colors show up.
>
> tt
>
>> On April 30, 2018 at 10:29 PM Chris Zwar <AE-List@media-motion.tv> wrote:
>>
>>
>> Hi,
>>
>> Just after some scripting help.  I have a simple script that works fine when run without a GUI, but if I use exactly the same code in a version with a GUI it doesn’t work any more.
>>
>> The aim is to sample the colour of a layer.  The script applies a colour control / expression control effect, with an expression that uses sampleImage to read the RGB values.  The script then reads the value of the colour control to get the RGB values.
>>
>> As I said - works fine if I run the script from the scripts menu.  But the same thing in a GUI and run from the ScriptsUI Panel doesn’t work. The RGB array variable is just 0. So what am I doing wrong?
>>
>> Cheers,
>>
>>
>> -Chris
>>
>> Offending code:
>>
>> myLayer[0].property("ADBE Effect Parade").addProperty("ADBE Color Control”);
>>
>> myLayer[0].property("ADBE Effect Parade").property("ADBE Color Control").property("ADBE Color Control-0001").expression="x=thisLayer.width/2;y=thisLayer.height/2; c=sampleImage([x,y], radius = [2, 2], postEffect = true, t = time);";
>>
>> var RGB=myLayer[0].property("ADBE Effect Parade").property("ADBE Color Control").property("ADBE Color Control-0001").value;
>>
>>
>> +---End of message---+
>> To unsubscribe send any message to <ae-list-off@media-motion.tv>
>
> +---End of message---+
> To unsubscribe send any message to <ae-list-off@media-motion.tv>


+---End of message---+
To unsubscribe send any message to <ae-list-off@media-motion.tv>



 
Subscribe (FEED) Subscribe (DIGEST) Subscribe (INDEX) Unsubscribe Mail to ListMaster