Software Developer's Kit - ChemDraw

Send comments on this topic
Group Property
See Also 


Member of ChemDraw Control.Symbol.

Sets and returns the group of this Symbol.

Property type

Read-write property


Visual Basic
Public Property Group() As Group

Return Type


group is a logical collection of objects.  A group is specially useful to associate disjoint fragments, in which case, GroupType will be kCDGroupTypeGroup. On the other hand, if the group has chemical significance, then GroupType will be kCDGroupTypeFragment.

Objects within a group can be selected individually and manipulated while still remaining part of the group. The property Integral specifies whether the group should be treated as a whole or not.

The following lines of code, when applied to a diagram with disjoint elements (example: a benzene with a disjoint element) produce the results indicated as comments next to the code:

Private Sub Command1_Click()
       On   Error Resume Next                   
       Dim vGroup As ChemDrawControl10Ctl.Group
       Dim vBond  As ChemDrawControl10Ctl.Bond
       Set  vBond  = ctlChemDraw.selection.Objects.Bonds.Item(1)
       Set  vGroup = ctlChemDraw.Objects.Groups.Item(1)
       Text1.Text = vGroup.ID             'returns the group id e.g. "5"
       'Text2.Text = vBond.Fragment.ID  'as it is a group, it cannot be fragment (variable not set)
       Text3.Text  = vBond.Group.ID    'returns the same ID as Text1 e.g. "5"
                                         End Sub 

 See Object.Fragment


'Object can be any ChemDraw object
 Private sub cmdMakeGroup_Click()
 If  Selection.Objects.Count = 0 Then 
     'there is no object selected
     varMakeGroup = True
     ‘there is at least one object selected
     If  Selection.Objects.Atoms.Count = 2 And Selection.Objects.Bonds.Count = 1 Then 
         'one bond selected – will be treated as bond 
         Set myBond = Me.ctlChemDraw.selection.Objects.Bonds.Item(1) 
         varMakeGroup = False
         Exit Sub
     End If

     If  Selection.Objects.Groups.Count = 1 Then 
         If  Selection.Objects.Count = Selection.Groups.Item(1).Objects.Count + 1 Then 
             ‘there is only one group and no objects outside of that group 
             Set MyGroup = Selection.Objects.Groups.Item(1) 
             varMakeGroup = False 
             Exit Sub 
            ‘there is one group and objects outside of that group 
             varMakeGroup = True 
             Exit Sub 
         End If 

         ‘there is more than one group 
         varMakeGroup = True
     End If
 End If

 If  varMakeGroup = True
     ‘creates a group with the objects in the selection
     Set MyGroup = ctlChemDraw.MakeGroup()
     For  x = 1 To (Selection.Objects.Count - 1)
          Selection.Objects.Item(x).Group = MyGroup
     Next x  
 End If
 End Sub

See Also