Software Developer's Kit - ChemDraw

Send comments on this topic
Fragment Property
See Also 


Member of ChemDraw Control.Bracket.

Sets and returns the fragment for this bracket.

Property type

Read-write property


Visual Basic
Public Property Fragment() As Group

Return Type


A fragment is a collection of connected atoms and bonds. A ChemDraw drawing may contain one or more fragments. If you cannot trace a path of atoms connected by bonds between two atoms, then they reside in different fragments.

A fragment is a chemical entity (differs from group, in that a group is a logical collection, and can be made up of disjoint elements).

Object.fragment is derived from group and enables all group properties and methods.

The following lines of code, when applied to a diagram of connected objects (example: a benzene with no 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 'returns the same ID as Text1 e.g. "5"
       'Text3.Text  = vBond.Group.ID     'as it is a Fragment, it cannot be a group (variable not set)
End Sub

 See Object.Group


'In the form general section (Or as public in the module) 
 Dim myObject As ChemDrawControl10Ctl.Object
 Private Sub Command1_Click() 
    'verifies if object belongs to a group or a fragment 
     If  MyObject.Fragment.GroupType = 1 Then 
GroupType = 1 indicates kCDGroupTypeFragment 

         vMessage = MsgBox("The number of bonds in this fragment is: " & _
                    myObject.Fragment.Bonds.Count, vbInformation + vbOKOnly, "Info") 
'GroupType = 0 indicates kCDGroupTypeGroup 
End If
End Sub

See Also