Skip to main content
Adirai Maji
Inspiring
May 25, 2020
Question

Is it possible to pick color from to another layer using scripting?

  • May 25, 2020
  • 2 replies
  • 2101 views

Here's what I want to achieve.

Let's say I've two rectangles filling an artboard in two half. one of the rectangle have fill color.

and I want a script that actually picks up the fill color from that rectangle's center position and fill that color on other rectangle. Here I don't want to use fill color property of the layer, I want to use position property of layer to pick the color. How can I do that?

 

Thanks in advance.

This topic has been closed for replies.

2 replies

pixxxelschubser
Community Expert
Community Expert
May 25, 2020

No apology is required.

I see what you want - but I don't think that is possible in a way like this.

 

The only two variants (except in actions) for calling a ColorPicker (that I know) in Javascript are:

 

var col1 = app.showColorPicker(new RGBColor());
alert (col1.red+" "+col1.green+" "+col1.blue);
var col2 = $.colorPicker();
alert (col2);

 

 

-----------------------

Unfortunately your screen recording is very very small, more like a stamp. There is not so much to see.

 

But it seems:

  • you have two layers
  •  not layer#1 is red --> in layer#1 is a red rectangle over the whole artboard
  • in layer#2 there are two rectangles - a big grey one and a small green one

 

Why not looking for the smaller rectangle in layer#2, gets it's fill color and set this color as fill color for the rectangle in layer#1 ? For my part this could be a good and possible solution.

 

Maybe you could show one screenshot (again) but bigger and with (really) opened Layers Panel (to see all existing paths) or upload a sample file (with no private informations) to a hoster of your choice and link to here?

 

Adirai Maji
Inspiring
May 26, 2020

Thank you for response..

Why not looking for the smaller rectangle in layer#2, Because I just shown what I needed in easy example. Instead of rectangle in layer#2 I've bunch of images here.I just want to eyedrop the center of that image to layer#1.

 

In this time I'll show you the example with image in layer#2

 

I just want to know how to use eyedropper tool automatic way using script. and detect the center of a layer and it's position on artboard. This would help to accomplish the need.

 

 

renél80416020
Inspiring
May 26, 2020

Salut!

var docRef = app.activeDocument;
docRef.layers[1].pathItems[0].fillColor = docRef.layers[0].pathItems[0].fillColor;

Bon courage...

 

pixxxelschubser
Community Expert
Community Expert
May 25, 2020

Hi @AdiraiMaji,

I think I didn't understand.

 

Can you show something? Before and after? With opened Layers Panel?

Adirai Maji
Inspiring
May 25, 2020

 

(Sorry for the glitch in screen recording) I've two layers. Layer 1 is fully red. Layer 2 is gray most part and in the center it's green.

 

I want to change the red layer to green (which is center of layer2) via scripting. I want to use layer 2's center point color to apply on layer 1. Hope you got my question now. I want to use the  layer's center point as color picking area.... Is it possible?