Copy link to clipboard
Copied
Hello,
Newbie here.
I added my swatches to my CC library, which shows my swatches for NEW documents; however, each time I open an old document, I need to add my swatches to my palette from the library. Is there a way adjust my palette to show only the swatches I use (again, this is for previous documents, not new)? I work for a company and revise documents all the time & use only the same color swatches over & over. Very inconvenient to have to continually add the swatches to my palette from my library on every document.
Thanks in advance for any advice!
You could get a list of your current default colors and add them to an old document via scripting. With the old document in front, try running this script:
//an existing document
var olddoc = app.activeDocument;
//a list of the old document‘s colors
var oldSwatches = getSwatchList(olddoc.swatches)
//open a new doc to get current default colors
var defdoc = app.documents.add();
var defColors = defdoc.swatches;
//add the default colors to the old doc
for (var i = 0; i < defColors.length; i++)
...
With no documents open create the desired swatches (or load an .ase swatches file) and restart ID.
There is an option to migrate your preferences when you upgrade, in the future you might want to do that.
Copy link to clipboard
Copied
I don't think there is, for preexisting documents. If you add the swatch with all docs closed, it will be there when you create a new doc.
Copy link to clipboard
Copied
Thanks for your response. They're there when I start a new doc, but I update existing docs daily and was hoping there was a way to add the swatches so they're in my palette when I open an existing doc.
Thanks again!
Copy link to clipboard
Copied
You could get a list of your current default colors and add them to an old document via scripting. With the old document in front, try running this script:
//an existing document
var olddoc = app.activeDocument;
//a list of the old document‘s colors
var oldSwatches = getSwatchList(olddoc.swatches)
//open a new doc to get current default colors
var defdoc = app.documents.add();
var defColors = defdoc.swatches;
//add the default colors to the old doc
for (var i = 0; i < defColors.length; i++){
if (!checkItem(oldSwatches, defColors[i].name)) {
var p = defColors[i].properties;
var s = olddoc.colors.add();
s.properties = p;
}
};
//close the defaults doc
defdoc.close(SaveOptions.NO)
/**
* Checks if an item is in an array
* @Param the array to check
* @Param the item to look for
* @Return true if the item is in the array
*
*/
function checkItem(a, obj) {
for (var i = 0; i < a.length; i++) {
if (a[i] === obj) {
return true;
}
}
return false;
}
/**
* get a list of swatch names
* @Param an array of swatches
* @Return a name list
*
*/
function getSwatchList(a){
sList = []
for (var i = 0; i < a.length; i++) {
sList.push(a[i].name)
}
return sList;
}
Copy link to clipboard
Copied
Rob,
You're a genius! That worked like a charm!
Thanks so much for your help!
Copy link to clipboard
Copied
@rob day Since I installed the 2021 update, unfortunately, this script no longer works. It was working beautifully and made my work flow so much more efficient.
Is there a different script I could try for 2021 InDesign?
Thanks a million!
Copy link to clipboard
Copied
Are you getting an error dialog?
Copy link to clipboard
Copied
No error, the colors just no longer appear in my swatch panel.
Thanks for any guidance.
Copy link to clipboard
Copied
When you did the update did you update your custom default swatches with no documents open?
Copy link to clipboard
Copied
No, I didn't. I didn't realize I needed to and don't know how.
Would you please advise on how to do that?
Thank you!
Copy link to clipboard
Copied
With no documents open create the desired swatches (or load an .ase swatches file) and restart ID.
There is an option to migrate your preferences when you upgrade, in the future you might want to do that.
Copy link to clipboard
Copied
That worked! Thank you again!