Finding color property of a shape layer.
Is there an efficient way to find the "Fill" color of a shape layer. As a shape layer can have multiple shapes inside, I want my script to be able to find all fills and replace them. I can do the replacement part, but I can't figure out a way to efficiently find the fills. Also Im running into trouble when there are fills that are grouped a couple of times.
To scout a shape layer, you can use a generic recursive function like the one below:
The argument 'groupHandler' is itself a function and tells what to do with the immediate content of the shape layer or group inside it.
In case the 'thing to do' is remove or reorganize children, it should be written in a way no error is thrown (!)
For instance, to change fills to gradient fills, it could be:
And apply this way:
That's one way to do, you can rewrite your own, but hopefully you get the spirit.
Wow, thank you very much, this is really useful.
But unfortunately I am running into an issue. I got it to change the fill with a value in a predefined variable, BUT it seems to be breaking the recursion when I try to slip some more information in the functions.
Disregard my previous comment... I overly complicated it for no reason.
love this snippet!
Is there a way to get these colors from the shape layer and add a color control for every found color?
That would be amazing!
Give this a try , this works for me (sorry to make such a mess on the Xavier's awesome code! I surely added a lot of redundant and messy lines out there, but it works for now)
the extra code I added looks for any stroke color in the layer and adds a color control and links the stroke color to that color control
And the name given to the color control effect is the name of the group the stroke belongs to (only the 1st level). If the stroke is outside a group, it has the name of the stroke (usually Stroke 1).
Ah, it works on all selected shape layers, so you can select a bunch of them.
Now, if any real coder here could give a clean, and more important, could add a function to prevent the code adding the same color control over and over each time you execute the script (in case you add a new group, or stroke, or have updated anyhing inside the shape layer and just want to update the color controls or add the new ones and keep the old ones without adding them again and again), that will be also more than welcome :)