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.
Copy link to clipboard
Copied
​
doc.swatches.item("gradient").remove();
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
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.
Copy link to clipboard
Copied
Hi,
What does the use of the word "gradient" mean? …
In my Sample: …
Playing a personal script [I'll give it for free // locked for Flavio's present use => "gradient" + "None" color]:
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
Copy link to clipboard
Copied
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:
It's still there, just unnamed…
Regards,
Uwe