Copy link to clipboard
Copied
Hi all, I'm trying to figure out a way to automate a simple, yet repetative process I do countless times a day. Ideally, I'd like to tie it to a keystroke to speed up my workflow.
I work on line art and colorways for footwear, so the way I'm coloring these shapes and strokes helps to break apart the different materials and pieces of the shoe.
While coloring line art, I work with Pantone spot colors as fills for closed path objects. I then have to manually apply that same color to the stroke, set the stroke to 0.5px weight, convert that spot stroke color to CMYK, and add 15% to the K value.
I found some code in an older post for applying the actively selected object's fill color to the stroke, but I'm having but I'm having trouble with the next step of figuring out how to take that spot stroke color and convert it to a CMYK build that I can then add 15% black to. Is this something that's even possible? I've spent about an hour playing with the script and have only had luck matching the fill color or turning the stroke white. Thanks for the help!
ok try this one, I added the spot color option
...// make stroke color same as fill color + 15% black increase
if ( app.documents.length > 0 && app.activeDocument.pathItems.length > 0) {
for (var a=0; a<app.selection.length; a++) {
try {
var sel = app.selection;
var fillcolor = sel.fillColor;
if (fillcolor.typename == "CMYKColor")
var cmkycolor = fillcolor;
else if (fillcolor.typename == "SpotColor")
Copy link to clipboard
Copied
it seems possible, post what you have so far and we'll try to help you complete it.
Copy link to clipboard
Copied
Great, I'll have to wait until tomorrow morning when I get to work, but I'll post my code and hopefully we can work through it.
Copy link to clipboard
Copied
Ok, here's where I got to with the code. Changing the stroke color to the fill color works fine, but I feel like I'm not understanding how to use CMYKColor;, or if I'm even using it in the right context. I'm trying to use it as a convert to CMYK command. Then I want to take that converted CMYK build and add 15% to the K value.
if ( app.documents.length > 0 && app.activeDocument.pathItems.length > 0) {
for (var a=0; a<app.selection.length; a++)
{
try {
app.selection.strokeColor = app.selection.fillColor;
app.selection.strokeWidth = 0.5;
app.selection.strokeColor = CMYKColor;
app.selection.strokeColor = ((app.selection.strokeColor.black) + 15);
}
catch (e){
}
}
}
Copy link to clipboard
Copied
Which values (C, M, Y, K) has the final color?
If every path in the document will have the new color?
Copy link to clipboard
Copied
Sorry, I may not have explained this before. I only want to change the currently selected object's stroke color. So only one object will change.
Although, in some cases, there are groups of objects, in which case I would like to change the strokes of the entire group at once. But if that isn't possible, I'm fine direct-selecting one object and just eye-droppering the rest.
And the final color should be based off of a CMYK conversion of a spot color which is currently being used as the fill, with an additional 15% added to the K value. It will be a different color for each object depending on what the fill is. I'm not changing to one consistant stroke color every time.
Copy link to clipboard
Copied
try this, select your paths before running
// make stroke color same as fill color + 15% black increase
if ( app.documents.length > 0 && app.activeDocument.pathItems.length > 0) {
for (var a=0; a<app.selection.length; a++) {
try {
var sel = app.selection;
var cmkycolor = sel.fillColor;
var col = new CMYKColor;
col.cyan = cmkycolor.cyan;
col.magenta = cmkycolor.magenta;
col.yellow = cmkycolor.yellow;
var black = cmkycolor.black + cmkycolor.black+15;
col.black = black>100 ? 100 : black;
sel.strokeColor = col;
sel.strokeWidth = 0.5;
}
catch (e){alert(e)
}
}
}
Copy link to clipboard
Copied
Thanks, I didn't think to define in the C, M, and Y values as well, but that makes sense.
I'm getting an error now when I run the script though:
Error: Numeric value expected
Copy link to clipboard
Copied
are your colors cmyk? spot? can you show your colors before running the script?
Copy link to clipboard
Copied
The fill colors are generally Spot CMYK, but are sometimes Spot RGB depending on the Pantone palette that is loaded. For the most part, they are never a regular CMYK build to start.
When I do this process manually, I convert the Spot Color to a regular CMYK build, then add 15% to the K value. I have a picture here if it helps to illustrate what I'm trying to do.
Also, for Black fills, I usually lighten the K value a bit to show some contrast, but I can figure out the code for that later. I just want to get the basic script working first.
Thanks for the help so far!
Copy link to clipboard
Copied
ok, then the error you're getting is when the script tries to read the cmyk values of off an rgb color, right?
it works with cmky fill colors right?
Copy link to clipboard
Copied
It's interesting, it throws the error for both RGB and CMYK Spot colors, but on a basic CMYK fill, it will apply a stroke matching that fill color, but won't increase the K value at all.
Copy link to clipboard
Copied
ok try this one, I added the spot color option
// make stroke color same as fill color + 15% black increase
if ( app.documents.length > 0 && app.activeDocument.pathItems.length > 0) {
for (var a=0; a<app.selection.length; a++) {
try {
var sel = app.selection;
var fillcolor = sel.fillColor;
if (fillcolor.typename == "CMYKColor")
var cmkycolor = fillcolor;
else if (fillcolor.typename == "SpotColor")
var cmkycolor = fillcolor.spot.color;
var col = new CMYKColor;
col.cyan = cmkycolor.cyan;
col.magenta = cmkycolor.magenta;
col.yellow = cmkycolor.yellow;
var black = cmkycolor.black + cmkycolor.black +15;
col.black = black>100 ? 100 : black;
sel.strokeColor = col;
sel.strokeWidth = 0.5;
}
catch (e){alert(e)
}
}
}
Copy link to clipboard
Copied
Thanks so much! That if/else if was the trick. Thanks again for the help, this will be great for speeding up my work, and I wouldn't have been able to work out that solution on my own.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now