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

Replace existing swatches in an ID doc

New Here ,
Apr 11, 2022 Apr 11, 2022

Copy link to clipboard

Copied

When loading swatches, is there a way to overwrite existing swatches within a document with a new set which may contain the same color name(s) but different cmyk values?

 

For example, the exisiting doc may contain a color called COLOR1 w/ cmyk values of 1, 2, 3, 4. We have tweaked the values for COLOR1 and they are now 2, 3, 4, 5. When loading the new .ase file, the existing values of COLOR1 are not updated with the values found in our new .ase file.

 

Thank you.

 

ID 17.2

OS 12.0.1

TOPICS
How to

Views

97

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 ,
Apr 11, 2022 Apr 11, 2022

Copy link to clipboard

Copied

Im not aware of a way to overwrite existing swatches with another ASE.

However, I've brought new color values in and done a Find and Replace to mass update to the new set.

Right click the swatch you want to replace and choose "Find this Color" (ID 2021 or newer).

You can then replace with your new color.

kevinstohlmeyer_0-1649700845372.png

 

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
Guru ,
Apr 11, 2022 Apr 11, 2022

Copy link to clipboard

Copied

LATEST

Here's a quick & dirty script I wrote for you. In fact, this is a part of another complex script.

It has a list of swatches: name and CMYK values pairs.

If a swatch doesn't exist, it will be created with the values in the list. If it does already exist, but the values are not the same, they will be corrected.

Use the list as a template and enter your values.

/* Copyright 2022, Kasyan Servetsky
April 11, 2022
Written by Kasyan Servetsky
http://www.kasyan.ho.ua
e-mail: askoldich@yahoo.com */
//======================================================================================
var scriptName = "Check Swatches",
debugMode = false, // for debugging only
doc;

app.doScript(PreCheck, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, "\"" + scriptName + "\" Script");

//===================================== FUNCTIONS ======================================
function Main() {
	try {
		// List of swatches: name, [ C, M, Y, K ]
		var swatches = [
			["Administration", [0, 60, 40, 10]],
			["Audit, Governance & Compliance", [0, 40, 90, 10]],
			["Behavioral", [40, 50, 20, 0]],
			["Engineering & Maintenance", [30, 35, 70, 10]],
			["Facility Management", [35, 15, 25, 35]],
			["Finance & Accounting", [60, 0, 85, 15]],
			["Financial Services", [70, 0, 70, 15]],
			["Healthcare", [55, 20, 70, 10]],
			["Human Resources", [0, 80, 80, 15]],
			["Information Technology", [50, 35, 0, 10]],
			["LEORON Mint/Tirkiz", [70, 20, 35, 0]],
			["LEORON Petroleum", [67, 50, 42, 15]],
			["Management & Leadership", [15, 80, 40, 10]],
			["Procurement & Contracts", [70, 0, 30, 15]],
			["Projects", [40, 20, 55, 10]],
			["Quality Management", [80, 50, 0, 15]],
			["Risk Management", [15, 15, 90, 15]],
			["Sales & Marketing", [0, 90, 50, 15]],
			["Supply Chain & Operations", [60, 15, 20, 20]]
		];
		
		CheckSwatches(swatches);
	}
	catch(err) {
		alert("Something went wrong: " + err.message + ", line: " + err.line, scriptName, true);
	}
}
//--------------------------------------------------------------------------------------------------------------------------------------------------------
function CheckSwatches(swatches) {
	var swatch, color;
	
	for (var i = 0; i < swatches.length; i++) {
		swatch = doc.swatches.itemByName(swatches[i][0]);
		if (debugMode) $.writeln(i + " - " + swatches[i][0] + " | " + swatches[i][0]);
		
		if (swatch == null) {
			color = doc.colors.add({name : swatches[i][0], model : ColorModel.PROCESS, space : ColorSpace.CMYK, colorValue : swatches[i][1]});
			if (debugMode) $.writeln("added color " + color.name);
		}
		else if (swatch.colorValue.join() != swatches[i][1].join()) {
			if (debugMode) $.writeln("changing colorValue - " + swatch.colorValue + " => " + swatches[i][1]);
			swatch.colorValue = swatches[i][1];
		}
	}
}
//--------------------------------------------------------------------------------------------------------------------------------------------------------
function PreCheck() {
	if (app.documents.length == 0) ErrorExit("Please open a document and try again.", true);
	doc = app.documents[0];
	if (doc.converted) ErrorExit("The current document has been modified by being converted from older version of InDesign. Please save the document and try again.", true);
	if (!doc.saved) ErrorExit("The current document has not been saved since it was created. Please save the document and try again.", true);

	Main();
}
//--------------------------------------------------------------------------------------------------------------------------------------------------------
function ErrorExit(error, icon) {
	alert(error, scriptName, icon);
	exit();
}
//--------------------------------------------------------------------------------------------------------------------------------------------------------

 

2022-04-11_22-23-52.png 

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