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

Eliminating an element by spot color name

New Here ,
Jan 03, 2024 Jan 03, 2024

Copy link to clipboard

Copied

Does anyone have a script that would locate an object by Spot Color name and delete it? Specifically, we have a customer that places a "Live" area box that I always have to delete. I would like to simply run an action that would delete it automatically so I don't have to search all the layers to find it.

TOPICS
Scripting

Views

106

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
Community Expert ,
Jan 03, 2024 Jan 03, 2024

Copy link to clipboard

Copied

On mobile, but something like this?

 

var doc = app.activeDocument;

var apis = doc.allPageItems;

var i = apis.length;

while(i--) {

if (apis[i].filled && apis[i].fillColor.name == "SwatchName") { apis[i].remove(); }

}

 

Hopefully you can get your client to appreciate the value of putting nonprinting items on their own layer(s).

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
New Here ,
Jan 03, 2024 Jan 03, 2024

Copy link to clipboard

Copied

Yes....something like that. Only a stroke not a fill.

With some conversation with the client, we are hoping to get them to understand proper file creation. 

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
Community Expert ,
Jan 03, 2024 Jan 03, 2024

Copy link to clipboard

Copied

LATEST

Hi @Joseph34576598wd3q , I’m getting an error with @brian_p_dts ’s code—I think apis[i].filled is a typo. This includes a dropdown dialog of document swatches with Brian’s code edited, and gets the page item‘s stroke color

 

var cs;
var d = app.dialogs.add({name:"Stroke Color", canCancel:true});
with(d){
    with(dialogColumns.add()){
        cs = dropdowns.add({stringList:app.activeDocument.swatches.everyItem().name, selectedIndex:0, minWidth:80});
    } 
    if(d.show()){
        cs = app.activeDocument.swatches.everyItem().getElements()[cs.selectedIndex];
        var apis = app.activeDocument.allPageItems;
        var i = apis.length;
        while(i--) {
            if (apis[i].strokeColor.name == cs.name) { apis[i].remove(); }
        }
        d.destroy();
    }
}

 

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