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

Remove unused Swatch Groups

Explorer ,
Feb 10, 2024 Feb 10, 2024

Hi, guys!

Is there any script code to remove unused core sample group? I know the code to erase color swatches, but not groups.
Exmple to remove color swatches (not groups):

 

var allDocs = app.documents;

for (var i = 0; i < allDocs.length; i++) {
trashUnusedSwatch (allDocs[i]);
}

function trashUnusedSwatch(myDocument){
var id, sw;
while (myDocument.unusedSwatches[0].name != "") {
id = myDocument.unusedSwatches[0].id;
sw = myDocument.swatches.itemByID(id);
sw.remove();
}
}

 

TOPICS
Feature request , How to , Scripting
278
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

Participant , Feb 10, 2024 Feb 10, 2024

Try this:

var allDocs = app.documents;

for (var i = 0; i < allDocs.length; i++) {
    trashUnusedSwatchGroups (allDocs[i]);
}

function trashUnusedSwatchGroups(myDocument){
    for (var j=myDocument.colorGroups.count()-1; j>=0; j--) {
        if(myDocument.colorGroups[j].colorGroupSwatches.length == 0) {
            myDocument.colorGroups[j].remove();
        }
    }
}
Translate
Participant ,
Feb 10, 2024 Feb 10, 2024

Try this:

var allDocs = app.documents;

for (var i = 0; i < allDocs.length; i++) {
    trashUnusedSwatchGroups (allDocs[i]);
}

function trashUnusedSwatchGroups(myDocument){
    for (var j=myDocument.colorGroups.count()-1; j>=0; j--) {
        if(myDocument.colorGroups[j].colorGroupSwatches.length == 0) {
            myDocument.colorGroups[j].remove();
        }
    }
}
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
Explorer ,
Feb 11, 2024 Feb 11, 2024
LATEST

Thanks so much!

 

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