Iterating through selected grouped items

As the title says, I’m having trouble iterating through selected records, more specifically when they’re in nested groups, and the api documentation seems really vague on this topic.

Since I need to edit each of the selected items, I use commands.ungroup(), and that works fine when there are only items in groups. However this commands ungroups just the first level of groups, so I need to use it again, but at that point all selected items are available only in selection.items, and there’s no indication to which group these items belong. Neither do I seem to be able to assign these values to an object and recreate all the grouping.

Does anyone have a suggestion on how to achieve this?

Thanks in advance

1 Like