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

Script for exporting LAB Color swatch values to Excel (CSV)

Enthusiast ,
Oct 15, 2019 Oct 15, 2019

Copy link to clipboard

Copied

Not sure this landed on the right place. Where is the scripting part of the forum? Was it deleted? All that work...

 

(This post is not a question.)

Below you will find a sample script for exporting LAB color swatches from InDesign. InDesign seem to have difficulties keeping thousands of swatches in its palette, so take care. A variant of this script made for Illustrator or Photoshop would probably have been a better idea.

 

 

 

/*
	Script for exporting LAB colours from InDesign Swatches. 
	Number, Name, L, A, and B columns semi colon separated.
	By Andreas Jansson, Code Combinations AB, Sweden, 2019.
	
	Description:
	First import a library of Pantone Colours so that they are present in the swatches palette of InDesign (you can export swatches from Photoshop, to an ASE file that is importable in InDesign).
	Then alter the path below to a folder of your choice and run this script with InDesign.
	The resulting file, I pasted into Excel.
*/

var result = '';
for (var i = 0; i <= app.swatches.length-1; i++){	
	var currentSwatch = app.swatches[i];
	if (currentSwatch.hasOwnProperty('space') && currentSwatch.space == ColorSpace.LAB){
		var val = currentSwatch.colorValue;
		result += i.toString() + ';' + currentSwatch.name + ';' + val[0] + ';' + val[1] + ';' + val[2] + '\r\n';
	}
}
result = 'N:o;Name;Lightness;A;B' + '\r\n' + result;
var outPath = 'C:/temp/test/out.txt';  // Put an existing path here
alert(writeToFile (result, outPath));

function writeToFile(fileContents, destinationFilePath){
	var myFileOut = new File(destinationFilePath);
	myFileOut.open('w');
	// myFileOut.encoding = 'UTF-8';
	myFileOut.write(fileContents);
	myFileOut.close();
	return new File(destinationFilePath).fsName;
}

 

 

 

 

TOPICS
Scripting

Views

2.0K

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
Enthusiast ,
Mar 14, 2024 Mar 14, 2024

Copy link to clipboard

Copied

Yes, in "English" but the friendly ".de" extension tells you this is not in the US. Weird.
It does not matter. I'm just saying...

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 ,
Mar 14, 2024 Mar 14, 2024

Copy link to clipboard

Copied

quote

Yes, in "English" but the friendly ".de" extension tells you this is not in the US. Weird.
It does not matter. I'm just saying...


By @Roger Breton

 

This should explain a lot:

https://www.indesignjs.de/extendscriptAPI/illustrator-latest/#about.html

 

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
Enthusiast ,
Mar 15, 2024 Mar 15, 2024

Copy link to clipboard

Copied

Hallo Robert,

 

Vielen danke fûr der dokumentation!!! Es ist wunderbar!!!

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 ,
Mar 15, 2024 Mar 15, 2024

Copy link to clipboard

Copied

LATEST
quote

Hallo Robert,

 

Vielen danke fûr der dokumentation!!! Es ist wunderbar!!!


By @Roger Breton

 

It's not mine. 

 

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