Sg2.9
How to ungroup?
Recent RSS
How to ungroup?
From:  alta
Date:  3. May 2012, 00:12

Hi,

Can anyone help me to solve this: how to ungroup the selected grouped items?

Thanks you in advanced
//A

Re: How to ungroup?
Date:  3. May 2012, 00:24

CTL-SHIFT-G is pretty good :-)
but i guess (and hope) you didnt mean that in a Scriptographer forum......

Re: How to ungroup?
From:  pqbd
Date:  3. May 2012, 00:58

for(i=0;i<group.children.length;i=0){document.activeLayer.appendBottom(group.children[0]);}

Re: How to ungroup?
From:  alta
Date:  3. May 2012, 07:23

@ gareth, funny observation!

@ pqbd, thanks for the tip, It worked like a charm...

Best
//A

Re: How to ungroup?
From:  alta
Date:  4. May 2012, 12:49

The idea of moving them out one by one is clever. But it should be an easier way to include it in Scriptographer... Anyways, here is my version of the idea! I'm not sure if the "While loop is more risky".

while(group.hasChildren()){
	document.activeLayer.appendBottom(group.children[0]);
}

Thanks for the help.
//A

Re: How to ungroup?
Date:  4. May 2012, 23:58

have you tried -- and I haven't time to check it just now

for all items in group
item.parent -> current layer // rather than group

group.remove() // otherwise it hangs around

Re: How to ungroup?
Date:  8. May 2012, 00:50

Back on the computer
My suggestion failed in a couple of ways....

Setting the parent to layer does not remove from the group - because the attribute is readonly -- helps if one scrolls down a bit in the reference :-(

The group is deleted as a side effect when the last item is appended to the parent layer - so no need for a group.remove().
When adding a group it can be left empty and needs removing if unused - I assumed this would be the same!

An improvement to the method, by the way, is to have

while(gp.children.length) {
gp.parent.appendBottom(gp.children[0]);
}

which deals with groups in groups.

I have not yet checked the code to leave the ungrouped items at the right place in the stacking order in the parent ... too late in the evening.

Scripts
08.08.14, 15:24
15.05.14, 14:23
02.03.14, 19:16
18.11.13, 14:48
22.03.13, 03:05
22.02.13, 15:45
Posts
10.01.17, 16:37
19.02.16, 06:03
19.02.16, 06:00
17.01.16, 11:00
12.01.16, 13:10
25.11.15, 08:19
Script of the Moment
Convert GPS .csv files to Illustrator paths 28.12.11