Showing results for 
Search instead for 
Did you mean: 

Add objects to a group

Gears Phenom Gears Phenom
Gears Phenom

I am trying to add selected objects on a sheet to a group as below and getting "Type Mismatch' error on the last line:


Dim oGroup As SolidEdgeFrameworkSupport.Group
oGroup = oGroups.Add("ABC")

Dim Objects(oSel.Count - 1) As Object 'oSel is a valid SelectSet

For i As Integer = 0 To oSel.Count - 1
  Objects(i) = oSel(i + 1)

oGroup.AddToGroup(oSel.Count, Objects)


I am not able to understand which of the argument types are not matching in the last line

  • First one which is of type Long, or

  • Second argument which is an array of objects.

The array of objects is valid and contains the selected objects (circles) and also the Count is a positive number.




Any help is highly appreciated.



Re: Add objects to a group

Solution Partner Phenom Solution Partner Phenom
Solution Partner Phenom

The following code is working for me, so how did you populate the selectset? Interactively or through code?

Dim objDoc As DraftDocument = objApp.ActiveDocument
Dim objSheet As Sheet = objDoc.ActiveSheet
Dim objGroups As Groups = objSheet.Groups
Dim objGrp As Group = objGroups.Add("ABC")
Dim objSelSet As SelectSet = objDoc.SelectSet
If objSelSet.Count > 0 Then
  Dim objs(objSelSet.Count - 1) As Object
  For i As Integer = 0 To objSelSet.Count - 1
    objs(i) = objSelSet.Item(i + 1)
  objGrp.AddToGroup(objSelSet.Count, objs)
End If

I used ST6 MP6!

Re: Add objects to a group

Gears Phenom Gears Phenom
Gears Phenom

Thanks for the reply Martin.

The selection set is populated interactively.

Though the code you provided doesn't appear much different than mine, can you please check if the code works when just one object is selected.

I am now getting issues when there is only one object even when using your code and interestingly when I run through the code in debug mode, it somehow appears to work.

Would it be possible for you to check your code with just one object selected ?

Thanks again.