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

Is it possible to move swatches, sort or reorder them?

Engaged ,
Mar 09, 2023 Mar 09, 2023

Copy link to clipboard

Copied

I'm looking to organize my Illustrator files a bit through scripting, and I'd like to be able to reorder swatches. I was hoping it was as simple as setting an index to an integer but it's not possible. The script I have loops through all document swatches and adds them to a Swatch Group, and I'm left with the patterns in the document, in whatever order they started.

 

A few ideas of how to accomplish if it's not as simple as changing the index:

Can I delete and readd the swatch to the panel?

Am I able to sort swatches via scripting? I searched through menu commands and it doesn't look like it's possible, but this would be an easy loop to organize.

TOPICS
Scripting

Views

396

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
Engaged ,
Mar 10, 2023 Mar 10, 2023

Copy link to clipboard

Copied

Sorting is possible with a trick:

1) Create an action with the command from the Swatches > Sort by Name panel menu.
2) Add a sequential number to the existing swatch names. For example: red > 2@red, green > 1@green
3) Execute the action. It will sort the swatches according to our indexes.
4) Loop through the swatch names in the document and delete the "Num@" prefix.

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
Engaged ,
Mar 10, 2023 Mar 10, 2023

Copy link to clipboard

Copied

Thanks! Good solution. Actions won't work for me, since calling a script with an action through an action causes the script to crash if I recall.

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
Engaged ,
Mar 10, 2023 Mar 10, 2023

Copy link to clipboard

Copied

Then there's a problem. Either we need to add the swatches in the desired order first, or we need a sort command that can only be accessed via actions =(

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
Engaged ,
Mar 10, 2023 Mar 10, 2023

Copy link to clipboard

Copied

LATEST

I thought of deleting and readding the swatches in order, but swatches.remove(); removes the fill from the document. I tried cutting a filled path, deleting the swatch, and pasting the path and it does reorder the swatches in the preferred order, but then of course the document is changed to a state that's not preferred.

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