Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


InDesign Script to manage swatches

Explorer ,
Nov 24, 2021 Nov 24, 2021

Copy link to clipboard

Copied

I put together a script to automatically import swatches and styles from another InDesign file. Is there anything extra I can add to the code that would keep it from duplicating my CMYK blend? it duplicates that color if i already have it in a file.

 

 

I'm also replacing old swatches with new and cant eliminate the tint swatch thats in my file. How do i include the tint swatch in my code to remove or replace it.

 

var myDoc = app.activeDocument;
var preFile = File.openDialog ("Select file");

//load swatches
var _loadSwatches = preFile;
if ( _loadSwatches != null ) {
try { app.activeDocument.loadSwatches ( _loadSwatches ) }
catch ( _ ) { alert ( _ ) }
}

//replace swatches
try { myDoc.colors.item("PANTONE Neutral Black C 90%").remove("PANTONE 426 C");}
catch (e) {}

 

 

 

TOPICS
How to, Scripting

Views

69

Likes

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

correct answers 2 Correct answers

Explorer , Nov 29, 2021 Nov 29, 2021
If anyone sees this later needing a solution ...  If I load swatch from an .ase file it will duplicate any CMYK blend swatches I may already have,  however if I import swatches from an InDesign file, it will not duplicate the swatch.

Likes

Translate

Translate
Explorer , Nov 29, 2021 Nov 29, 2021
i also got this script from someone that will eliminate tint swatches//remove swatch tint removeTintsOfColor(myDoc, "PANTONE Neutral Black C"); function removeTintsOfColor(doc, colorOrName) { var color; if (colorOrName.constructor.name == 'String') { color = doc.swatches.itemByName(colorOrName); } else if (colorOrName.constructor.name == 'Color') { color = colorOrName; } if (color == undefined || !color.isValid) return; var tints = doc.tints; for (var ...

Likes

Translate

Translate
Explorer ,
Nov 24, 2021 Nov 24, 2021

Copy link to clipboard

Copied

disregard duplicating swatch question, I'm not able to reproduce the issue I was having and i'm able to import swatches without duplicating any.

Likes

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 ,
Nov 29, 2021 Nov 29, 2021

Copy link to clipboard

Copied

If anyone sees this later needing a solution ...  If I load swatch from an .ase file it will duplicate any CMYK blend swatches I may already have,  however if I import swatches from an InDesign file, it will not duplicate the swatch.

Likes

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 ,
Nov 29, 2021 Nov 29, 2021

Copy link to clipboard

Copied

LATEST

i also got this script from someone that will eliminate tint swatches

//remove swatch tint
removeTintsOfColor(myDoc, "PANTONE Neutral Black C");
function removeTintsOfColor(doc, colorOrName) {
    var color;
    if (colorOrName.constructor.name == 'String') {
        color = doc.swatches.itemByName(colorOrName);
    } else if (colorOrName.constructor.name == 'Color') {
        color = colorOrName;
    }
    if (color == undefined || !color.isValid) return;
    var tints = doc.tints;
    for (var i = tints.length - 1; i >= 0; i--) {
        if (tints[i].baseColor == color)
            tints[i].remove("PANTONE Neutral Black C");}}

 

Likes

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