Software Developer's Kit - ChemDraw

Send comments on this topic
Group Object
See Also  Members 

Description

Member of ChemDraw Control.

For a list of all members defined for this object, see Group Members.

ChemDraw Group Class represents a group object. 

Object Model





















Remarks

Grouping creates an association between objects so they can be easily selected. You can select all grouped objects by double-clicking with a selection tool. Objects within a group can be selected individually and manipulated while still remaining part of the group.

If you want to group objects so that the individual objects in the group cannot be accessed, you can create an Integral group. When you select any object in an Integral group, the entire group is selected. This is done using the integral property.

Atoms and bonds making up a single chemical structure are always grouped and the resulting GroupType equals kCDGroupTypeFragment. If you group part of a structure with other objects, the resulting group contains the entire structure and GroupType equals kCDGroupTypeGroup. If you add atoms or bonds to a grouped structure, the new atoms and bonds are part of the group.

Example

Private sub cmdMakeGroup_Click()
If  Selection.Objects.Count = 0 Then 
    'there is no objected selected
    varMakeGroup = True
Else 
    ‘there is at least on 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 
        Else 
           ‘there is one group and objects outside of that group 
            varMakeGroup = True 
            Exit Sub 
        End If 
    Else

        ‘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 Sub

See Also