Copy link to clipboard
Copied
Hi,
I need to select and delete unused swatches in InDesign CS5. I looked through OMV in "Swatches" and "Swatch", but I could not find any function to select unused swatch and delete it.
Am I looking for it in the wrong place?
And I also need to read color values for used swatches. I got this in OMV and was hoping it would give me an array of the color values for all existing swatches, but I am only getting "Object color":
mySwatches = myDoc.swatches[1].getElements();
|
Thank you for your help.
Yulia
Copy link to clipboard
Copied
check this thread, i think siva prasath has answered this (it is the last post in the thread)
http://forums.adobe.com/message/4059167
it deletes unused swatches and gradients without any ramifications.
to make it more useful, try adding this line to the start of the script:
app.menuActions.item("$ID/Add All Unnamed Colors").invoke();
as this will add any unnamed colours to the list of swatches, and then siva's script will remove all of the unused swatches/gradients.
Copy link to clipboard
Copied
Hi Yuliaart,
Try this script it will help ful.
# target "Deleting unused swatches change the gradient"
var myIndesignDoc = app.activeDocument;
var myUnusedSwatches = myIndesignDoc.unusedSwatches;
for (var s = myUnusedSwatches.length-1; s >= 0; s--) {
var mySwatch = myIndesignDoc.unusedSwatches;
var name = mySwatch.name;
// alert (name);
if (name != ""){
mySwatch.remove();
}
}
Copy link to clipboard
Copied
Hi siva,
I am a beginner to Indesign scripting. I have a doubt in this script (Delete unused Swatches).
What is the correct meaning for the below command from your script? What this command actually did?
"if (name != "")"
I know, this command is used, not to affect the applied gradients, Can you please give some other similarity for this use of command?
I want to know the actual meaning and usage of this command
Can you please clear?
Copy link to clipboard
Copied
if the variable name does not equal nothing then remove the swatch.
Copy link to clipboard
Copied
hi,
i also used "siva's script for removing unused swatches.
my query is! do it say the name of the swatch deleted, as requested by Yuliaart, earlier.
thanks,
rajnikanth
Copy link to clipboard
Copied
The alert is commented out.
Copy link to clipboard
Copied
function trashUnusedSwatch(){
while (myDocument.unusedSwatches[0].name != "") {
id = myDocument.unusedSwatches[0].id;
sw = myDocument.swatches.itemByID(id);
sw.remove();
}
}
This should also work.
Copy link to clipboard
Copied
Love it!
Thank you.
Copy link to clipboard
Copied
Do you realize you gave yourself, as the OP, the “correct answer” instead of the actual user who answered it.