4

If you use an Illustrator action on a selection, it applies it to that selection as a whole.

Illustrator actions can be applied as 'batches', but this means batches of files, not batches of objects.

Is there a way to apply an action to each object in turn (like Transform Each does), not the whole selection?

2 Answers 2

2

With scripting yes. Modified the AI scripting docs:

var docSelected = app.activeDocument.selection;
if ( docSelected.length > 0 ) {
    if ( docSelected.length > 0 ) {
        for ( i = 0; i < docSelected.length; i++ ) {
            docSelected[i].selected = false;
            //Do Something to docSelected[i]
        }
    } else {
        docSelected.selected = false;
        //Do Something to docSelected[i]
    }
} else {
    alert( "Please select one or more art objects" );
}
1

This works:

var docSelected = app.activeDocument.selection;
if ( docSelected.length > 0 ) {
        var actionName = prompt("Which action do you want to run?", "");
        var set = prompt("Which set is your action in?", "Default Actions");
    for ( i = 0; i < docSelected.length; i++ ) {
        docSelected[i].selected = false;
    }
    app.activeDocument.selection = null;
    for ( i = 0; i < docSelected.length; i++ ) {
        docSelected[i].selected = true;
        app.doScript(actionName, set)
        docSelected[i].selected = false;
        app.activeDocument.selection = null;
    }
} else {
    alert( "Please select one or more art objects" );
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.