1

Okay, so this might be a little complicated.

In Adobe Illustrator (currently 25.4.1) I have a project that I'm doing, where a pattern of objects is on one layer, and there's an image on a locked layer beneath it. What I've been doing by hand is selecting one of the objects, and using the eyedropper tool to select a color from the image, more or less where center of the object would be. This colors the object from whatever pixel I clicked on, and I lather, rinse, and repeat.

I'm wondering if there might be a way to script this, so that I can select all the objects on the pattern layer, and have them all select the color from the pixel in the image that would be closest to the center of the object. Even if the script did the process object by object, that'd be fine because I don't mind telling the script to get to work and going to do something else until it's finished.

I tried recording the actions, but using the eyedropper to pick a color doesn't record an action, and I wasn't sure how to script finding the center of the object anyway.

Any help would be greatly appreciated. This is for a project where I need to do a couple of these designs every day, and it will probably become an annual thing.

Thank you all.

4
  • I could be wrong, but I believe it's not possible to script any Eyedropper click. That sort of user interaction is simply not scriptable because there's no way for the app to know where to click. But.. can you select objects and color them with scripts.. absolutely. You could record an action for that aspect with a hotkey.. so shift-click with Eyedropper, then hit a shortcut.
    – Scott
    Oct 7 at 18:20
  • Are you making something like low poly art?
    – Billy Kerr
    Oct 7 at 21:55
  • Thank's Scott, but unfortunately, once the color is picked, the action's done, so that wouldn't really help. And no, it's not really low poly art, but it is geometric designs.
    – David Alan
    Oct 8 at 3:07
  • There is no scripting interface for sampling pixels of raster objects. C++ API time.
    – joojaa
    Oct 8 at 5:02
2

Not sure about scripting this, but you could use Illustrator's Live Paint functionality to speed up such a task. This would avoid the problem of having to physically select anything.

Here's the process

  1. Draw shapes with a stroke and no fill.

  2. Select them all, and convert to a Live Paint Object using Object > Live Paint > Make

  3. Select the Live Paint Bucket tool

  4. Hold down Alt to switch to the Eyedropper, and click to sample inside a shape

  5. Release the Alt key, then click with the Live Paint Bucket to fill the shape with the colour you sampled.

  6. Repeat steps 4 and 5 until finished.

Example

enter image description here

2
  • Thank you. That'll definitely help speed me up. Not quite the automation solution I was hoping for, but that'll definitely be easier than selecting an object every time.
    – David Alan
    Oct 8 at 3:08
  • @DavidAlan - You're welcome. Glad that helps a bit.
    – Billy Kerr
    Oct 8 at 9:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.