forked from zlovatt/zl_Scriptlets
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Ungroup Selected Shape Groups.jsx
45 lines (36 loc) · 1.01 KB
/
Ungroup Selected Shape Groups.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/**
* Ungroups all selected shape groups.
*
* Note: This assumes that each group ONLY has a 'path' within it.
* If there's more, it'll fail.
*
* @author Zack Lovatt <[email protected]>
* @version 0.2.1
*/
(function ungroupSelectedShapeGroups() {
var comp = app.project.activeItem;
if (!(comp && comp instanceof CompItem)) {
alert('Please select a composition!');
return;
}
var props = comp.selectedProperties;
var parentProp = props[0].propertyGroup();
var idxList = [];
var ii, il;
// Build list of indices
for (ii = 0, il = props.length; ii < il; ii++) {
idxList.push(props[ii].propertyIndex);
}
app.beginUndoGroup('Ungroup Selected Shape Groups');
app.executeCommand(2004); // Deselect all
// Deselect them
for (ii = 0, il = idxList.length; ii < il; ii++) {
var prop = parentProp.property(idxList[ii]);
prop.selected = true;
try {
app.executeCommand(3742);
} catch (e) {}
parentProp.property(idxList[ii]).selected = false;
}
app.endUndoGroup();
})();