Software Developer's Kit - ChemDraw

Send comments on this topic
Overlaps Method
See Also 
newVal
newVal is a ChemDrawControl rectangle

Description

Member of ChemDraw Control.Rect.

Indicates whether the intersection of this rectangle with another rectangle is non-empty, or not.  

Syntax

Visual Basic
Public Function Overlaps( _
   ByVal newVal As Rect _
) As Boolean

Parameters

newVal
newVal is a ChemDrawControl rectangle

Return Type

Boolean

Remarks

The expression:

(myRect1.Overlaps(myRect2)) will return True if the intersection of Rect1 with Rect2 is not empty.

(myRect1.Overlaps(myRect2)) will return False if the intersection of Rect1 with Rect2 is empty.

Example

'Declares the variables
 Dim myObject  As ChemDrawControl10Ctl.Object
 Dim vObject1 As ChemDrawControl10Ctl.Object
 Dim vObject2 As ChemDrawControl10Ctl.Object
 Dim Rect1  As ChemDrawControl10Ctl.Rect
 Dim Rect2  As ChemDrawControl10Ctl.Rect
'Checks that there is an object loaded in the variable 
 Private Sub ctlChemDraw_SelectionChanged (ByVal Selection As
         ChemDrawControl10Ctl.IChemDrawSelection)
   'Verifies what has been selected 
    If  Selection.Objects.Count < 1 Then
        Exit Sub
'exits if there is nothing selected 
    End If

   'Works with two objects
    Dim i As Integer
    i = 0 
    For Each myObject In Selection.Objects
       If  myObject.Selected = True Then
           Set
vObject = myObject
           If  i = 0 Then
               
Set vObject1 = ChemDrawControl10Ctl.ActiveDocument.Selection.Objects.Item(1)
           End If
           If 
i = 1 Then
               
Set vObject2 = ChemDrawControl10Ctl.ActiveDocument.Selection.Objects.Item(2)
           End If
           i = i + 1
       End If
    Next
End Sub

Private Sub cmdOverlaps_Click()
   'Example of Rect.Overlaps
    Set Rect1 = vObject1.Bounds
    Set Rect2 = vObject2.Bounds
   'This will return True if Rect1 intersection Rect2 is not empty
    Text1.text = Rect1.Overlaps(Rect2)
End Sub

See Also