Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How can I apply a current fill color to a stroke, then adjust that stroke color's build?

New Here ,
Apr 09, 2013 Apr 09, 2013

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!

TOPICS
Scripting
2.3K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Apr 10, 2013 Apr 10, 2013

ok try this one, I added the spot color option

add15percentBlack.png

// 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")

             

...
Translate
Adobe
Community Expert ,
Apr 09, 2013 Apr 09, 2013

it seems possible, post what you have so far and we'll try to help you complete it.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 09, 2013 Apr 09, 2013

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 10, 2013 Apr 10, 2013

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){

          }

     }

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 10, 2013 Apr 10, 2013

Which values ​​(C, M, Y, K) has the final color?
If every path in the document will have the new color?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 10, 2013 Apr 10, 2013

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 10, 2013 Apr 10, 2013

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)

        }

    }

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 10, 2013 Apr 10, 2013

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 10, 2013 Apr 10, 2013

are your colors cmyk? spot? can you show your colors before running the script?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 10, 2013 Apr 10, 2013

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!

Screen shot 2013-04-10 at 3.09.45 PM.JPG

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 10, 2013 Apr 10, 2013

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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 10, 2013 Apr 10, 2013

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 10, 2013 Apr 10, 2013

ok try this one, I added the spot color option

add15percentBlack.png

// 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)

        }

    }

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 11, 2013 Apr 11, 2013
LATEST

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines