home *** CD-ROM | disk | FTP | other *** search
- Attribute VB_Name = "modEditCircle"
- '******************************************************************'
- '* *'
- '* TurboCAD for Windows *'
- '* Copyright (c) 1993 - 2001 *'
- '* International Microcomputer Software, Inc. *'
- '* (IMSI) *'
- '* All rights reserved. *'
- '* *'
- '******************************************************************'
-
-
- 'Before start this script it is necessary to create some objects and to select a part from them
-
-
- Public Sub CircleEdit()
- ' Edits coordinates of the centre and radius of a selected circle
- Dim App As Application
- Dim ActDr As Drawing
- Dim Grs As Graphics
- Dim Gr As Graphic
- Dim Vers As Vertices
- Dim Ver As Vertex
- Dim ObjSel As Selection
- Dim NumSel As Long, i As Long
- Dim GrSelType As String
-
- Set App = IMSIGX.Application 'Returns base application - TurboCAD
- Set ActDr = App.ActiveDrawing 'Returns Active Drawing
- Set ObjSel = ActDr.Selection 'Returns Selected objects as Selection collection
- NumSel = ObjSel.Count 'Returns the number of items in the collection.
-
-
- If NumSel = 0 Then
- MsgBox ("No circle was selected.Please select the circle and try again")
- Exit Sub
- End If
- For i = 0 To NumSel - 1
- Set Gr = ObjSel.Item(i) 'Returns part of a collection - graphic in the selection collection
- GrSelType = Gr.Type
- If GrSelType = "CIRCLE" Then
- Set Vers = Gr.Vertices ' Return the Vertices collection for current graphic - Circle
- Set Ver = Vers.Item(0) ' This Vertex is the center of the circle
- Dim XcOld#, YcOld# ' coordinates of the center of the circle
- Dim Xr#, Yr# ' coordinates the point on the circle
- Dim ROld#
- XcOld = Ver.X
- YcOld = Ver.Y
- Set Ver = Vers.Item(1) 'This Vertex lies on the circle
- Xr = Ver.X
- Yr = Ver.Y
- ROld = Sqr((Xr - XcOld) * (Xr - XcOld) + (Yr - YcOld) * (Yr - YcOld))
- frmEditCircle.TextBox1.Text = CStr(XcOld)
- frmEditCircle.TextBox2.Text = CStr(YcOld)
- frmEditCircle.TextBox3.Text = CStr(ROld)
- frmEditCircle.Show
- Gr.Unselect
-
- Dim XcNew#, YcNew#
- Dim RNew#
- XcNew = CDbl(frmEditCircle.TextBox1.Text)
- YcNew = CDbl(frmEditCircle.TextBox2.Text)
- RNew = CDbl(frmEditCircle.TextBox3.Text)
- Dim Matr As Matrix ' A transformation matrix
- Dim xScale#, yScale#
- Dim dx#, dy#
- xScale = RNew / ROld
- yScale = RNew / ROld
- dx = XcNew - XcOld
- dy = YcNew - YcOld
- Set Matr = Gr.Scale(xScale, yScale, 1) 'Scales the Graphic object.
- Set Matr = Gr.MoveRelative(dx, dy, 0) 'Moves the Graphic object by a specified offset
- End If
- Next i
- ActDr.Views(0).Refresh
- End Sub
-