Now that you have created a dialog box, you can modify and add code.
Public trad As Double ' Updated
Public tspac As Double ' Updated
Public tsides As Integer ' Add
Public tshape As String ' Add
trad and tspac, you update their definitions to make them public. Private variables are available only in the module in which they are defined, so the variables need to be changed to public. Additionally, you have added tsides for the number of polygon tile sides and tshape for the user's choice of tile shape, which is either circle or polygon.
Because the code in the form accessestrad = ThisDrawing.Utility. _
GetDistance(sp, "Radius of tiles: ")
tspac = ThisDrawing.Utility. _
GetDistance(sp, "Spacing between tiles: ")
Load gpDialog
gpDialog.Show
'Draw the tile with the designated shape
Sub DrawShape(pltile)
Dim angleSegment As Double
Dim currentAngle As Double
Dim angleInRadians As Double
Dim currentSide As Integer
Dim varRet As Variant
Dim aCircle As AcadCircle
Dim aPolygon As AcadLWPolyline
ReDim points(1 To tsides * 2) As Double
'Branch based on the type of shape to draw
Select Case tshape
Case "Circle"
Set aCircle = ThisDrawing.ModelSpace. _
AddCircle(pltile, trad)
Case "Polygon"
angleSegment = 360 / tsides
currentAngle = 0
For currentSide = 0 To (tsides - 1)
angleInRadians = dtr(currentAngle)
varRet = ThisDrawing.Utility.PolarPoint(pltile, _
angleInRadians, trad)
points((currentSide * 2) + 1) = varRet(0)
points((currentSide * 2) + 2) = varRet(1)
currentAngle = currentAngle + angleSegment
Next currentSide
Set aPolygon = ThisDrawing.ModelSpace. _
AddLightWeightPolyline(points)
aPolygon.Closed = True
End Select
End Sub
Select Case statement to branch control of the program based on the type of shape to draw. The tshape variable is used to determine the type of shape.
This subroutine uses aSet cir = ThisDrawing.ModelSpace.AddCircle(pltile, trad)
Change these lines to draw the appropriate shape tile, as follows:
DrawShape (pltile) ' Updated