Probably easiest to do it using AIActionManagerSuite::PlayActionEvent("adobe_group", kDialogNone, NULL);
The other way would be to use AIMatchingArtSuite::GetSelectedArt and then create a new group object and add the selected art:
But you would probably have to filter the art to prevent the problem described here:
PlayActionEvent with adobe_group is the first thing I tried.
After that I retrieve the current selected object with GetSelectedArt. This function returns the hierarchy of the selected object not only the group I made
The parent of this group is marked selected as its parent and so on ..
How can I retrieve only the group I made and skip the hierarchy ?
Is it enough to pick the first object that is selected with the following conditions :
1) The object is a group
2) The object must not be an artlayer group
3) Its children are all selected
I see there is a problem getting the group art created by PlayActionEvent.
I don't have much experience of using AIMatchingArtSuite::GetSelectedArt, but if the order of the art returned is parents before children then I think your method will work.
Another option might be to call GetSelectedArt before PlayActionEvent and store all the art handles in a set and then call GetSelectedArt after PlayActionEvent and compare the result with the previous set, hopefully there will be only one new art object.
What if you create a new group using AIArtSuite::NewArt?
The add to the group the selected items one by one by taking them using AIArtSetSuite::SelectedArtSet
(+keep just once each item, eliminate the children whose parents are selected, I think),
adding to the group by AIArtSuite::ReorderArt (use kPlaceInsideOnTop or kPlaceInsideOnBottom, depending on your logic)?