想求多个面域的累加周长,怎么做?有一段代码是求多个面域的累加面积的,程序正确.我把其中的area必成list ,想求周长,但运行时出错.
求累加面积的正确代码:
 ublic Sub carea()
On Error GoTo ErrorHandler
Dim pt As Variant Dim spt As String Dim i As Integer Dim zarea As Double zarea = 0
For i = 0 To 500 pt = ThisDrawing.Utility.GetPoint(, vbCrLf & "输入要计算面积对象的内部一点:")
spt = pt(0) & "," & pt(1)
With ThisDrawing SendCommand "-boundary " SendCommand spt & " " SendCommand " " SendCommand "area " SendCommand "o " SendCommand "last " SendCommand "erase " SendCommand "last " SendCommand " " End With
zarea = zarea + ThisDrawing.GetVariable("AREA") ThisDrawing.Utility.Prompt vbCrLf & "选定对象的总面积为: " & zarea & vbCrLf Next
ErrorHandler: Exit Sub End Sub
我改后的代码:
Public Sub clist() Dim pt As Variant Dim spt As String Dim i As Integer Dim zlist As Double zlist = 0
For i = 0 To ThisDrawing.ModelSpace.Count pt = ThisDrawing.Utility.GetPoint(, vbCrLf & "输入要计算周长对象的内部一点:")
spt = pt(0) & "," & pt(1)
With ThisDrawing SendCommand "-boundary " SendCommand spt & " " SendCommand " " SendCommand "list" SendCommand "last " SendCommand "erase " SendCommand "last " SendCommand " " End With
zlist = ThisDrawing.GetVariable("list") ThisDrawing.Utility.Prompt vbCrLf & "选定对象的总面积为: " & zlist Next
ErrorHandler: Exit Sub End Sub
请大家多多指教,不胜感激. |