Copy link to clipboard
Copied
Good afternoon,
I am able to create unnamed colour using following code.
app.menuActions.item("$ID/Add All Unnamed Colors").invoke();
I am trying to move unnamed colours in colorGroups folder named "newAddedColor".
Can anybody share the code to move new added unnamed color in a particular colorGroups folder.
Thanks,
/Sdhar/
Try something like this:
...var doc = app.documents[0];
var swatches = doc.swatches.everyItem().getElements();
app.menuActions.item("$ID/Add All Unnamed Colors").invoke();
var newSwatches = doc.swatches.everyItem().getElements();
var group = doc.colorGroups.item('newAddedColor');
if(!group.isValid){
group = doc.colorGroups.add('newAddedColor');
}
for(var i=0;i<newSwatches.length;i++){
var s = newSwatches;
if(isNewSwatch(s,swatches){
group.colorGroupSwatches.add(s);
}
}
function isNewSwatch(swatch,swat
Copy link to clipboard
Copied
Try something like this:
var doc = app.documents[0];
var swatches = doc.swatches.everyItem().getElements();
app.menuActions.item("$ID/Add All Unnamed Colors").invoke();
var newSwatches = doc.swatches.everyItem().getElements();
var group = doc.colorGroups.item('newAddedColor');
if(!group.isValid){
group = doc.colorGroups.add('newAddedColor');
}
for(var i=0;i<newSwatches.length;i++){
var s = newSwatches;
if(isNewSwatch(s,swatches){
group.colorGroupSwatches.add(s);
}
}
function isNewSwatch(swatch,swatches){
for(var i=0;i<swatches.length;i++{
var s = swatches;
if(s.name == swatch.name){return false}
}
return true;
}
Copy link to clipboard
Copied
Harbs,
Thanks for your prompt answer. You are great.
Thanks,
--Sdhar
Copy link to clipboard
Copied
From someone who is still very much a newbie at scripting InDesign, this is pretty slick. Thanks!
Copy link to clipboard
Copied
Glad it works. It's nice when you type into the forum and it just works on the first try... 😉