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

move unnamed color to the folder

Guest
Jan 10, 2017 Jan 10, 2017

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/

TOPICS
Scripting

Views

575

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

correct answers 1 Correct answer

LEGEND , Jan 10, 2017 Jan 10, 2017

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

...

Votes

Translate

Translate
LEGEND ,
Jan 10, 2017 Jan 10, 2017

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;

}

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
Guest
Jan 10, 2017 Jan 10, 2017

Copy link to clipboard

Copied

Harbs,

Thanks for your prompt answer. You are great.

Thanks,

--Sdhar

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
Participant ,
Jan 10, 2017 Jan 10, 2017

Copy link to clipboard

Copied

From someone who is still very much a newbie at scripting InDesign, this is pretty slick. Thanks!

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
LEGEND ,
Jan 10, 2017 Jan 10, 2017

Copy link to clipboard

Copied

LATEST

Glad it works. It's nice when you type into the forum and it just works on the first try... 😉

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