Copy link to clipboard
Copied
Why this script doesn't end? The idea is to ungroup all the groups in the doc.
var doc = app.activeDocument;
var exit;
while (true) {
exit = true;
app.executeMenuCommand("selectall");
var sel = doc.selection;
for (var i = 0; i < sel.length; i++) {
var item = sel[i];
if (item.typename === "GroupItem") {
app.executeMenuCommand("ungroup");
alert('ungrouped!');
exit = false;
break;
}
}
while (doc.selection.length > 0) {
app.executeMenuCommand('deselectall');
app.redraw();
}
if (exit) break;
}
alert('exit while loop');
1 Correct answer
The reason is that in Illustrator, clipping masks are also a group.
Explore related tutorials & articles
Copy link to clipboard
Copied
The reason is that in Illustrator, clipping masks are also a group.
Copy link to clipboard
Copied
Désolé @andyf65867865 mais votre script n'est pas correct, il comporte plusieurs fautes ou maladresses.
(entre autres, la boucle for peut être parcourue de nombreuses fois...)
var compound = true;
app.executeMenuCommand("selectall");
app.executeMenuCommand("ungroup");
if (compound) {
app.executeMenuCommand("noCompoundPath");
}
selection = null;
René
Copy link to clipboard
Copied
@renél80416020Thanks for the comments, indeed one operator turns out to be unnecessary, forcing the for loop to run unnecessary times in the case of multiple outer groups. However, the compound path type is a separate type and it was not necessary to “parse” it. Also, note that the line `selection = null` should be followed with redraw otherwise it will not work correct.

