home *** CD-ROM | disk | FTP | other *** search
- Attribute VB_Name = "modRRect"
- '******************************************************************'
- '* *'
- '* TurboCAD for Windows *'
- '* Copyright (c) 1993 - 2001 *'
- '* International Microcomputer Software, Inc. *'
- '* (IMSI) *'
- '* All rights reserved. *'
- '* *'
- '******************************************************************'
-
- Public Sub RoundRectangle()
- ' Create 2D-RoundRectangle with holes
- Dim App As Application
- Dim ActDr As Drawing
- Dim Grs As Graphics
- Dim Gr As Graphic
- Dim a#, b#, R#, r1#
- Dim X0#, y0#
- Dim Pi#
- Pi = 3.14159
- X0 = 5
- y0 = 5
- frmRRect.Show
- a = CDbl(frmRRect.TextBox1.Text)
- b = CDbl(frmRRect.TextBox2.Text)
- R = CDbl(frmRRect.TextBox3.Text)
- r1 = CDbl(frmRRect.TextBox4.Text) / 2
- If R <= 0 Then R = 0
- If r1 > R Then r1 = 0
- Set App = IMSIGX.Application 'Returns an Application object - TurboCAD
- Set ActDr = App.ActiveDrawing 'Returns the active Drawing object
- Set Grs = ActDr.Graphics 'Returns the Graphics collection for active Drawing object
- If R = 0 Then
- 'Creates and adds a rectangle to the Graphics collection.
- Set Gr = Grs.AddLineRectangle(X0 - a / 2, y0 - b / 2, 0, X0 + a / 2, y0 + b / 2, 0)
- Gr.Properties("PenWidth") = 0.03 'Changes the Graphic Property - "PenWidth"
- Else
- ' Add Line segments
- Set Gr = Grs.AddLineSingle(X0 - a / 2 + R, y0 - b / 2, 0, X0 + a / 2 - R, y0 - b / 2, 0)
- Gr.Properties("PenWidth") = 0.03
- Set Gr = Grs.AddLineSingle(X0 + a / 2, y0 - b / 2 + R, 0, X0 + a / 2, y0 + b / 2 - R, 0)
- Gr.Properties("PenWidth") = 0.03
- Set Gr = Grs.AddLineSingle(X0 - a / 2 + R, y0 + b / 2, 0, X0 + a / 2 - R, y0 + b / 2, 0)
- Gr.Properties("PenWidth") = 0.03
- Set Gr = Grs.AddLineSingle(X0 - a / 2, y0 - b / 2 + R, 0, X0 - a / 2, y0 + b / 2 - R, 0)
- Gr.Properties("PenWidth") = 0.03
- ' Add Arcs
- Set Gr = Grs.AddArcCenterAndPoint(X0 - a / 2 + R, y0 - b / 2 + R, 0, X0 - a / 2 + R, y0 - b / 2, 0, Pi, 3 * Pi / 2)
- Gr.Properties("PenWidth") = 0.03
- Set Gr = Grs.AddArcCenterAndPoint(X0 + a / 2 - R, y0 - b / 2 + R, 0, X0 + a / 2 - R, y0 - b / 2, 0, 3 * Pi / 2, 2 * Pi)
- Gr.Properties("PenWidth") = 0.03
- Set Gr = Grs.AddArcCenterAndPoint(X0 + a / 2 - R, y0 + b / 2 - R, 0, X0 + a / 2 - R, y0 + b / 2, 0, 0, Pi / 2)
- Gr.Properties("PenWidth") = 0.03
- Set Gr = Grs.AddArcCenterAndPoint(X0 - a / 2 + R, y0 + b / 2 - R, 0, X0 - a / 2 + R, y0 + b / 2, 0, Pi / 2, Pi)
- Gr.Properties("PenWidth") = 0.03
- ' Add Circles
- If r1 > 0 Then
- Set Gr = Grs.AddCircleCenterAndPoint(X0 - a / 2 + R, y0 - b / 2 + R, 0, X0 - a / 2 + R, y0 - b / 2 + R + r1, 0)
- Gr.Properties("PenWidth") = 0.03
- Gr.Properties("PenColor") = RGB(0, 255, 0)
- Set Gr = Grs.AddCircleCenterAndPoint(X0 + a / 2 - R, y0 - b / 2 + R, 0, X0 + a / 2 - R, y0 - b / 2 + R + r1, 0)
- Gr.Properties("PenWidth") = 0.03
- Gr.Properties("PenColor") = RGB(0, 255, 0)
- Set Gr = Grs.AddCircleCenterAndPoint(X0 + a / 2 - R, y0 + b / 2 - R, 0, X0 + a / 2 - R, y0 + b / 2 - R + r1, 0)
- Gr.Properties("PenWidth") = 0.03
- Gr.Properties("PenColor") = RGB(0, 255, 0)
- Set Gr = Grs.AddCircleCenterAndPoint(X0 - a / 2 + R, y0 + b / 2 - R, 0, X0 - a / 2 + R, y0 + b / 2 - R + r1, 0)
- Gr.Properties("PenWidth") = 0.03
- Gr.Properties("PenColor") = RGB(0, 255, 0)
- End If
- End If
- End Sub
-
- Public Sub RRectWithThick()
- ' Create 3D-RoundRectangle with holes as surface
- Dim App As Application
- Dim ActDr As Drawing
- Set App = IMSIGX.Application
- Set ActDr = App.ActiveDrawing
- Dim Space%
- Space = ActDr.Properties("TileMode")
- If Space <> 1 Then
- MsgBox ("This macros works only in Model Space")
- Exit Sub
- End If
- Dim Grs As Graphics
- Dim Gr As Graphic
- Dim GrChild As Graphic
- Dim a#, b#, R#, r1#, Thick#
- Dim X0#, y0#
- Dim Pi#
- Pi = 3.14159
- X0 = 5
- y0 = 5
- frmRRect.Show
- a = CDbl(frmRRect.TextBox1.Text)
- b = CDbl(frmRRect.TextBox2.Text)
- R = CDbl(frmRRect.TextBox3.Text)
- r1 = CDbl(frmRRect.TextBox4.Text) / 2
- Thick = CDbl(frmRRect.TextBox5.Text)
- If R <= 0 Then R = 0
- If r1 > R Then r1 = 0
- Set Grs = ActDr.Graphics
- Set Gr = Grs.Add(7) ' graphic of Group type
- If R = 0 Then
- Set Gr = Grs.AddLineRectangle(X0 - a / 2, y0 - b / 2, 0, X0 + a / 2, y0 + b / 2, 0)
- Else
- ' Add Line segments
- Set GrChild = Gr.Graphics.AddLineSingle(X0 - a / 2 + R, y0 - b / 2, 0, X0 + a / 2 - R, y0 - b / 2, 0)
- Set GrChild = Gr.Graphics.AddLineSingle(X0 + a / 2, y0 - b / 2 + R, 0, X0 + a / 2, y0 + b / 2 - R, 0)
- Set GrChild = Gr.Graphics.AddLineSingle(X0 - a / 2 + R, y0 + b / 2, 0, X0 + a / 2 - R, y0 + b / 2, 0)
- Set GrChild = Gr.Graphics.AddLineSingle(X0 - a / 2, y0 - b / 2 + R, 0, X0 - a / 2, y0 + b / 2 - R, 0)
- ' Add Arcs
- Set GrChild = Gr.Graphics.AddArcCenterAndPoint(X0 - a / 2 + R, y0 - b / 2 + R, 0, X0 - a / 2 + R, y0 - b / 2, 0, Pi, 3 * Pi / 2)
- Set GrChild = Gr.Graphics.AddArcCenterAndPoint(X0 + a / 2 - R, y0 - b / 2 + R, 0, X0 + a / 2 - R, y0 - b / 2, 0, 3 * Pi / 2, 2 * Pi)
- Set GrChild = Gr.Graphics.AddArcCenterAndPoint(X0 + a / 2 - R, y0 + b / 2 - R, 0, X0 + a / 2 - R, y0 + b / 2, 0, 0, Pi / 2)
- Set GrChild = Gr.Graphics.AddArcCenterAndPoint(X0 - a / 2 + R, y0 + b / 2 - R, 0, X0 - a / 2 + R, y0 + b / 2, 0, Pi / 2, Pi)
- ' Add Circles
- If r1 > 0 Then
- Set GrChild = Gr.Graphics.AddCircleCenterAndPoint(X0 - a / 2 + R, y0 - b / 2 + R, 0, X0 - a / 2 + R, y0 - b / 2 + R + r1, 0)
- Set GrChild = Gr.Graphics.AddCircleCenterAndPoint(X0 + a / 2 - R, y0 - b / 2 + R, 0, X0 + a / 2 - R, y0 - b / 2 + R + r1, 0)
- Set GrChild = Gr.Graphics.AddCircleCenterAndPoint(X0 + a / 2 - R, y0 + b / 2 - R, 0, X0 + a / 2 - R, y0 + b / 2 - R + r1, 0)
- Set GrChild = Gr.Graphics.AddCircleCenterAndPoint(X0 - a / 2 + R, y0 + b / 2 - R, 0, X0 - a / 2 + R, y0 + b / 2 - R + r1, 0)
- End If
- End If
- Dim GrHatch As Graphic
- Gr.Closed = True
- Set GrHatch = Gr.Graphics.AddHatch 'Adds a hatch pattern to the collection from the Graphic objects in the collection.
- GrHatch.Properties("PenColor") = RGB(255, 0, 0) 'Changes color of the hatch-object
- If Thick > 0 Then
- GrHatch.Properties("Thickness") = Thick 'Changes the property - "Thickness"
- GrHatch.Properties("Solid") = 0 ' Resulting object is Surface
- End If
- End Sub
-
-