: Apply an action to each item in a selection in turn? 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',
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?
More posts by @LarsenBagley460
2 Comments
Sorted by latest first Latest Oldest Best
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" );
}
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" );
}
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.