主要的问题是在提示用户获取点时没有先隐藏窗体,其它的在编程中注意一下就可以了。

- [FONT=courier new]
- Sub drawcircularpavers()
- Dim brickcircles() As AcadCircle
- Dim center As Variant, radius As Double
- Dim counter As Integer
- '这里首先应判断文本框是否有输入,是否是数字。
- if txtnumberofcircles="" then exit sub
- if not isnumeric(txtnumberofcircles) then exit sub
- ReDim brickcircles(txtnumberofcircles)
- '这里隐藏窗体
- frmcircleofbricks.hide
- With ThisDrawing.Utility
- center = .GetPoint(, "click the position for the center")
- radius = .GetDistance(center, "enter the radius")
- End With
- For counter = 0 To txtnumberofcircles - 1
- Set brickcircles(counter) = ThisDrawing.ModelSpace.AddCircle(center, (radius - counter * radius / txtnumberofcircles))
- brickcircles(counter).Color = acRed
- brickcircles(counter).Update
- '下面的语句在过程中定义了参数,但却没有对其赋值。
- drawmortar center, counter, radius
- Next
- End Sub
- Sub drawmortar(center As Variant, counter As Integer, radius As Double)
- Dim startpoint(0 To 2) As Double, endpoint(0 To 2) As Double
- Dim theta As Double, stepsize As Double
- Static adjust As Double
- If frmcircleofbricks.optbrickparallel = True Then
- stepsize = 15 * 3.1415 / 180
- Else
- stepsize = 30 * 3.1415 / 180
- If adjust = 0# Then
- adjust = 15 * 3.1415 / 180
- Else
- adjust = 0#
- End If
- End If
- For theta = 0 To 360 * 3.1415 / 180 Step stepsize
- startpoint(0) = (radius - counter * radius / txtnumberofcircles) * Cos(theta + adjust) + center(0)
- startpoint(1) = (radius - counter * radius / txtnumberofcircles) * Sin(theta + adjust) + center(1)
- endpoint(0) = (radius - (counter + 1) * radius / txtnumberofcircles) * Cos(theta + adjust) + center(0)
- endpoint(1) = (radius - (counter + 1) * radius / txtnumberofcircles) * Sin(theta + adjust) + center(1)
- startpoint(2) = 0#: endpoint(2) = 0#
- With ThisDrawing.ModelSpace
- .AddLine startpoint, endpoint
- 'Count前不能再有ModelSpace。
- .Item(.Count - 1).Update
- End With
- Next
- End Sub
- Private Sub cmdcancel_Click()
- Unload Me
- End Sub
- Private Sub cmdcreatepavers_Click()
- 'Unload Me 这里就不对了,还没执行程序就把窗体卸载了,后面的程序当然就不执行了。
- drawcircularpavers
- End Sub
- [/FONT]
|