Software Developer's Kit - ChemDraw

Send comments on this topic
Offset Method
See Also 
dx
dx is a double number which is the number of points (expressed in internal coordinates) to shift in the x direction. A positive value shifts towards the right
dy
dy is a double number which is the number of points (expressed in internal coordinates) to shift in the y direction. A positive value shifts towards the bottom

Description

Member of ChemDraw Control.Rect.

Moves the rectangle a specified distance.

Syntax

Visual Basic
Public Sub Offset( _
   ByVal dx As Double, _
   ByVal dy As Double _
) 

Parameters

dx
dx is a double number which is the number of points (expressed in internal coordinates) to shift in the x direction. A positive value shifts towards the right
dy
dy is a double number which is the number of points (expressed in internal coordinates) to shift in the y direction. A positive value shifts towards the bottom

Return Type

Rect

Remarks

This method shifts a rectangle by a specified number of points, as indicated by dx, dy. 

Example

'Declares the variables
 Dim myObject As ChemDrawControl10Ctl.Object
 
Dim vObject As ChemDrawControl10Ctl.Object 
 Dim Rect As ChemDrawControl10Ctl.Rect
'Checks that there is an object loaded in the variable
 If  Selection.Objects.Count < 1 Then 
     Exit Sub
 End If
'Loads the last object selected into the variable
 For Each myObject In selection.Objects
     If  myObject.Selected = True Then
         Set vObject = myObject
     End If
 Next

 Private Sub cmdOffset_Click()   
    'Example of Rect.Offset
     Set Rect = vObject.Bounds
     X = InputBox("These values are verified:" + Chr$(13) + _
         "[Variable].Bounds.TopLeft.X" + Chr$(13) + 
"[Variable].Bounds.BottomRight.X" + _
         Chr(13) & Chr(13) & "dx is expressed in points = CurCoords * 20", _
         "OFFSET - Please input value for dx", Format(Val(vObject.Bounds.TopLeft.Y), "0.00"))
     Y = InputBox("These values are verified:" + Chr$(13) + _
         "[Variable].Bounds.TopLeft.Y" + Chr$(13) + "[Variable].Bounds.BottomRight.Y" + _
         Chr(13) & Chr(13) & "dy is expressed in points = CurCoords * 20", _
         "OFFSET - Please input value for dy", Format(Val(vObject.Bounds.BottomRight.Y), "0.00")) 
    'Applies the offset method 
     myRect.Offset X, Y
    'Shows the coordinates of the offset rectangle
     vMessage = MsgBox("Rectangle after OFFSET" + _
                Chr(13) & "NEW.TopLeft.X: " & Format(Rect.TopLeft.X, "###.##") & _
                Chr(13) & "NEW.TopLeft.Y: " & Format(Rect.TopLeft.Y, "###.##") & _
                Chr(13) & "NEW.BottomRight.X: " & Format(Rect.BottomRight.X, "###.##") & _
                Chr(13) & "NEW.BottomRight.Y: " & Format(Rect.BottomRight.Y, "###.##"), _
                vbInformation + vbOKOnly, "Offset in a rectangle variable")  

 End Sub          

See Also