Skip to main content
Frans van der Vleuten
Known Participant
February 26, 2024
Question

Why swapping multiple colors of multiple objects at once not possible?

  • February 26, 2024
  • 1 reply
  • 237 views

Hello,

 

If you select an object in Illustrator, you can swap the fill and stroke colours of that objects, obviously.

If you select multiple objects with for example different stroke colors, the swapping tool is in ghost.

 

Why is this? The swapping of the colors is happening within the object. It should be a legitimate action to swap multiple objects with different colors.

 

Who's with me. 

 

 

 

 

This topic has been closed for replies.

1 reply

Kurt Gold
Community Expert
Community Expert
February 26, 2024

InDesign can do it by default. In Illustrator you may use a script.

 

Among others, @femkeblanco has written a good one (see below).

 

// Script by femkeblanco
// to swap fills and strokes of selected items
var array = [];
function push(items) {
    for (var i = 0; i < items.length; i++) {
        if (items[i].typename == "PathItem") {
            array.push(items[i]);
        } else if (items[i].typename == "GroupItem") {
            push(items[i].pageItems);
        } else if (items[i].typename == "CompoundPathItem") {
            push(items[i].pathItems);
        }
    }
}
push(app.selection);
for (var i = 0; i < array.length; i++) {
    var fill = array[i].fillColor;
    var stroke = array[i].strokeColor;
    array[i].fillColor = stroke;
    if (!array[i].stroked) array[i].stroked = true;
    array[i].strokeColor = fill;
}