Add a group as a sub-group to another group

Phenom
Phenom

I have two valid Group objects on a Draft sheet - oGroupA and oGroupB.

I am trying to add oGroupB as a sub-group under oGroupA and figured out two methods to accomplish this:

 

Method 1:

Dim Objects(0) As Object
Objects(0) = oGroupB
oGroupA.AddToGroup(, Objects)

 

Method 2:
oGroupA.Groups.Add(oGroupB.Name)

 

None of these seem to work.

There are no errors.

Any help is highly appreciated.

 

4 REPLIES

Re: Add a group as a sub-group to another group

Solution Partner Phenom Solution Partner Phenom
Solution Partner Phenom

The first method works for me with SE ST6 MP6:

Dim objDoc As DraftDocument = objApp.ActiveDocument
Dim objSheet As Sheet = objDoc.ActiveSheet
Dim objGroups As Groups = objSheet.Groups
Dim objGrpA As Group = objGroups.Item(1)
Dim objGrpB As Group = objGroups.Item(2)
Dim objs() As Object = {objGrpB}
objGrpA.AddToGroup(objs.Length, objs)

 

Re: Add a group as a sub-group to another group

Phenom
Phenom

Thanks Martin. It works well.

I think the difference lies in the way I was adding the group to the array.

Objects(0) = oGroupB

which differs and is perhaps not correct, compared to how you did:

Dim objs() As Object = {objGrpB}

 

Re: Add a group as a sub-group to another group

Solution Partner Phenom Solution Partner Phenom
Solution Partner Phenom

You are right. For single objects, the group is not added correctly and the graphic object disappears.

This seems to be a bug and you should report it to GTAC!!

Re: Add a group as a sub-group to another group

Phenom
Phenom

Martin, Thanks again for checking the code with a single object.

You mentioned the graphic object disappears. In my case the object is still seen but is not accesible - it is locked and not selectable with mouse. Occassionaly Solid Edge freezes and needs to be restarted.

 

I don't have access to GTAC but hopefully someone reads this and takes note for the ordeal does not end there. The Group command is messed up when used interactively too.

1. Cut a group and paste it into another sheet. The graphic moves to the other sheet but the group name under the tree in the PathFinder's Groups tab does not display the name of the group.

2. Same with copy - group copied from one sheet to another does not display its name in the PathFinder under the Group tab.

3. When a group is copied and pasted multiple times in the same sheet, it is not displayed in the Treeview - this could be working as designed.

4. When one of the copy-pasted group is renamed, its name is not updated in the Tree. It is accesible only through the command bar.

5. It is not possible to assign a name to a new group same as that of an existing group - an error is displayed, but this is possible through API - can create several groups with same name without throwing an exception.