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

colors

Participant ,
Jun 20, 2024 Jun 20, 2024

Copy link to clipboard

Copied

I have an InDesign 2024 document with 778 pages that includes 12 colors on all pages. I want to change these 12 colors to another set of 12 colors using a script.

TOPICS
How to , Performance , Scripting , SDK

Views

136

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 ,
Jun 20, 2024 Jun 20, 2024

Copy link to clipboard

Copied

Hi @aghanjar16430960 , Create or load the 12 new Swatches. When you delete a Swatch that is being used, you will be prompted to choose a replacement. It will take less time to manually replace the used colors than write a script.

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 ,
Jun 20, 2024 Jun 20, 2024

Copy link to clipboard

Copied

Do you mean CMYK plus 8 spot colours?

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
Explorer ,
Jun 20, 2024 Jun 20, 2024

Copy link to clipboard

Copied

LATEST

With this script you can replace the desired colour with a saved colour (ASE file) in one go. However, it only works with one colour at a time. You just have to do it twelve times.
It actually only simplifies the principle that rob day has already written

 

//DESCRIPTION:An imported color should replace an existing color
//Version: 1.0
//Autor: SteigART

#target Indesign

if(app.documents.length == 0){
    alert("No Document open");
}else{
    var doc = app.activeDocument;
    main(doc);
}

function main(doc){
    // A list of all colors in the document (required for comparison with the new list);
    var allColorOld = doc.swatches.everyItem().name;

    //Create a dialog window
    var dial = app.dialogs.add();
    dial.name = "Select the color to be replaced";
    var dialColum = dial.dialogColumns.add();
    var dropdown = dialColum.dropdowns.add();
    dropdown.stringList = allColorOld;

    // Dialog start
    var dialResult = dial.show();

    //Define the evaluation of the dialog and the color to be deleted
    if(dialResult){
        var selColor = doc.swatches[dropdown.selectedIndex].name;

        //Release dialog memory
        dial.destroy();

        // Load Color in Indesign
        importColor(doc, selColor, allColorOld);

    }else{
        dial.destroy();
    }

}


function importColor(doc, selColor, allColorOld){
    // Select color file (ASE-Datei)
    var ColorFile = File.openDialog("Choose an ASE file to import", "*.ase");
    
    // Check if the user has selected a file
    if(ColorFile === null){
        alert("No color file selected");
        return;
    }
    
    //Check if the selected file exists
    if(!ColorFile.exists){
        alert("The file does not exist: " + ColorFile.fullName);
        return;
    }
    
    // Import color from the ASE file
    doc.loadSwatches(ColorFile);
    
    // List with all colors in the document including the newly imported
    var allColorNew = doc.swatches.everyItem().name;

    // Compare color lists with each other and save the new color in variable
    for(i=0; i<allColorNew.length; i++){
        if(allColorOld[i] != allColorNew[i]){
            var newColor = allColorNew[i];
        }
    }

    // Create variable of the color selected at the beginning
    var delColor = doc.swatches.itemByName(selColor);

    // Delete the selected color and replace it with the imported one
    delColor.remove(newColor);
}

 

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