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

Helps remove color by name.

Participant ,
Oct 11, 2017 Oct 11, 2017

Copy link to clipboard

Copied

I need to select and remove all the colors that have the word "gradient" in their name and then replace them with none. Thank you for your help.

TOPICS
Scripting

Views

1.1K

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 ,
Apr 02, 2018 Apr 02, 2018

Copy link to clipboard

Copied

​

doc.swatches.item("gradient").remove();

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 ,
Apr 03, 2018 Apr 03, 2018

Copy link to clipboard

Copied

Hi Flavio,

your attempt in answer 1 here looks already very promising.

What's not working with it? Provided variable doc contains an open document…

Regards,
Uwe

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 ,
Apr 03, 2018 Apr 03, 2018

Copy link to clipboard

Copied

If you are on Macintosh you can use the following in AppleScript:

tell application "Adobe InDesign CC 2018"

  tell document 1

  try

  delete (every swatch where name contains "gradient") replacing with "None"

  end try

  end tell

end tell

For JavaScript I think you would have to use RegEx to get a list of the swatches and then parse through the list.

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
Guide ,
Apr 03, 2018 Apr 03, 2018

Copy link to clipboard

Copied

Hi,

What does the use of the word "gradient" mean? …

In my Sample: …

Capture d’écran 2018-04-03 à 18.54.12.png

Playing a personal script [I'll give it for free // locked for Flavio's present use => "gradient" + "None" color]:

Capture d’écran 2018-04-03 à 19.10.39.png

The result will be different:

• Swatch: 4

• Color: 2

• Gradient: 1

• Tint: 1

Note the Script uses a cool Grep syntax! …

Best,

Michel, from FRIdNGE

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 ,
Apr 03, 2018 Apr 03, 2018

Copy link to clipboard

Copied

LATEST

Hi Michel,

of course the result would be different.

Base code would be that:

colorWhoesNameHasGradient.remove("None");

However, the result could enforce some side effects. For objects affected: A strokeWeight value bigger than 0 would change the value to 0.

Another problem:

Try to remove a gradient that is selected in the Swatches Panel.

You could remove it from the Swatches Panel, but you cannot remove it from the Color panel or from the Fill or Stroke widget in the Swatches Panel:

GradientSelectedWithSwatchesPanel-Remnant-1.png

It's still there, just unnamed…

Regards,
Uwe

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