Copy link to clipboard
Copied
Copy link to clipboard
Copied
Hi @Nobat5C29, I've never used Indesign Server, so we might have to wait for an expert, but a perhaps there's a couple of things you could try. One is to write to the console to check that anything is happening, eg. maybe it isn't storing unused swatches? Another is (long shot!) to copy the Document.unusedSwatches to a normal array before removing it in case there is a referencing problem as the swatches are removed.
- Mark
var myDoc = app.documents.firstItem();
// copy to an array
var unusedSwatches = [];
for (var i = 0; i < myDoc.unusedSwatches.length; i++) {
unusedSwatches.push(myDoc.unusedSwatches[i]);
}
for (var i = unusedSwatches.length - 1; i >= 0; i--) {
// this line should write to the console in Indesign Server
app.consoleout("Removing unused swatch " + unusedSwatches[i].name);
unusedSwatches[i].remove();
}
Copy link to clipboard
Copied
The code looks fine and as you say it works on CC2020 then this makes it more interesting. As @m1b mentioned did you do some more debugging around this issue. Predominantely the following are the points that I would look into before coming to a conclusion that this is a bug.
Hope looking at these points and what @m1b pointed we more closer to a conclusion.
-Manan
Copy link to clipboard
Copied
I made a lot of different Tests with a reseller, who could try different versions and we found out, it depens on the InDesign Server insalation language in the higher verssions 16. and 17. In Version 15 everythink is working fine.
The Skritpt is working on InDesign Server Version 15, 16 and 17 english insallation, and Version 15 german insallation.
The Skript is not working on InDesign Server Version 16 and 17 in german insallation. I did an oher debug with this output:
Copy link to clipboard
Copied
last update: it is does not matter witch language is. It madders with the InDesign Server Version. InDesign Server 16.0 is working. InDesign Server 16.2.1 is not working.
In english Verion i get this errors:
Copy link to clipboard
Copied
Sounds like you are getting close to nailing down the issue. I assume you have tested the script with various documents, including a very simple one that you can document step-by-step how you made it. Then you can report the bug and include all the specifics of when it occurs in which version of Indesign Server etc.
- Mark
Copy link to clipboard
Copied
It looks like a bug to me as well. Need to report.
Copy link to clipboard
Copied
Hi together,
I came accross an issue that perhaps is related though, I see it in the current dektop version of my German InDesign 2023 on macOS ( had no chance to test with earlier versions or with a Windows version; will do later ) .
There is this feature Merge Swatches in the GUI. And also method merge() with Colors and Swatches in ExtendScript.
If you do this with unused swatches the remaining swatch in NOT listed in the unusedSwatches array.
The GUI will not select the remaining swatch as unused with menu command Select All Unused in the Swatches panel.
To see this with a new, default document:
[1] Add a new document.
[2] Open the Swatches panel.
[3] Use the menu command "Select All Unused".
[4] Use the menu command "Merge Swatches".
All selected swatches will be merged to one of the selected ones.
In our default document with a default German InDesign the remaining swatch of all removable swatches will be:
"C=0 M=0 Y=100 K=0".
[5] Use the menu command "Select All Unused".
Result: No swatch will be selected.
Is this a bug? And if not, where is the remaining swatch used?
Inspect the array app.documents[0].unusedSwatches.
The color named C=0 M=0 Y=100 K=0 is not listed.
Note: The array is perhaps not empty, because there could be unnamed colors that are not used and therefore are listed.
What I also tried in the GUI:
Find Colors > C=0 M=0 Y=100 K=0
Result: There are no instances found where the color is in use.
Regards,
Uwe Laubender
( Adobe Community Expert )
Copy link to clipboard
Copied
Hi again,
there is news with the case above.
Finally I could remove the remaining swatch of the previous merging of swatches.
I had to run the following script two times in a row:
( function()
{
app.doScript
(
deleteUnusedColors,
ScriptLanguage.JAVASCRIPT,
[],
UndoModes.ENTIRE_SCRIPT,
"Delete Unused Colors | SCRIPT"
);
function deleteUnusedColors()
{
if( app.documents.length == 0 ){ return };
var doc = app.documents[0];
var unusedColorsArray = doc.unusedSwatches;
for( var n=0; n<unusedColorsArray.length; n++ )
{
unusedColorsArray[n].remove();
};
};
}() )
Regards,
Uwe Laubender
( Adobe Community Expert )
Copy link to clipboard
Copied
Attached four InDesign documents in the order:
1-DefaultDocWithUnusedSwatches.indd
2-UnusedSwatches-MERGED-with-GUI-command.indd
3-DeleteUnusedColors-SCRIPT-RUN-1.indd
4-DeleteUnusedColors-SCRIPT-RUN-2.indd
Regards,
Uwe Laubender
( Adobe Community Expert )
Copy link to clipboard
Copied
Just another note:
I can see the issue with merging unused colors in the desktop version of InDesign 2020 and above.
For Windows and macOS.
Regards,
Uwe Laubender
( Adobe Community Expert )
Find more inspiration, events, and resources on the new Adobe Community
Explore Now