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

change all selection's filled color to black

Community Beginner ,
May 17, 2016 May 17, 2016

Copy link to clipboard

Copied

can some use script to change all selection's filled color to black. the selection object maybe have pathItems or other.

thank you

TOPICS
Scripting

Views

295

Translate

Translate

Report

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
Adobe
Community Expert ,
May 19, 2016 May 19, 2016

Copy link to clipboard

Copied

LATEST

If you're only working with pathItems and compoundPathItems, this script will work. If you've got groups within your selection, things get much more difficult because unless you can predict the grouping order and the number of subgroups, you need a recursive loop to ensure that all pathItems' colors are changed.

Hopefully this is good enough for ya. let me know.

function test()

{

    var docRef = app.activeDocument;

    var sel = docRef.selection;

    var blackColor = new CMYKColor();

    blackColor.cyan=0;

    blackColor.magenta=0;

    blackColor.yellow=0;

    blackColor.black=100;

    blackColor.name = "Script Defined Black";

    for(var a=0;a<sel.length;a++)

    {

        var thisSel = sel;

        if(thisSel.typename == "PathItem")

        {

            thisSel.fillColor = blackColor;

        }

        else if(thisSel.typename == "CompoundPathItem")

        {

            for(var b=0;b<thisSel.pathItems.length;b++)

            {

                var thisInnerSel = thisSel.pathItems;

                thisInnerSel.fillColor = blackColor;

            }

        }

    }

}

test();

Votes

Translate

Translate

Report

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