请问用什么算法能计算出封闭区域的面积
请问用什么算法能计算出封闭区域的面积 封闭区域如果是<A href="mk:@MSITStore:C:\Program%20Files\AutoCAD%202005%20cn\help\acadauto.chm::/idh_arc_object.htm" target="_blank" >Arc</A>, <A href="mk:@MSITStore:C:\Program%20Files\AutoCAD%202005%20cn\help\acadauto.chm::/idh_circle_object.htm" target="_blank" >Circle</A>, <A href="mk:@MSITStore:C:\Program%20Files\AutoCAD%202005%20cn\help\acadauto.chm::/idh_ellipse_object.htm" target="_blank" >Ellipse</A>, <A href="mk:@MSITStore:C:\Program%20Files\AutoCAD%202005%20cn\help\acadauto.chm::/idh_lightweightpolyline_object.htm" target="_blank" >LightweightPolyline</A>, <A href="mk:@MSITStore:C:\Program%20Files\AutoCAD%202005%20cn\help\acadauto.chm::/idh_polyline_object.htm" target="_blank" >Polyline</A>, <A href="mk:@MSITStore:C:\Program%20Files\AutoCAD%202005%20cn\help\acadauto.chm::/idh_region_object.htm" target="_blank" >Region</A>, <A href="mk:@MSITStore:C:\Program%20Files\AutoCAD%202005%20cn\help\acadauto.chm::/idh_spline_object.htm" target="_blank" >Spline</A>中的一种,则可以直接使用Area属性来取得面积 用-boundary命令生成面域 请问版主:在VBA中是如何使用-boundary来生成面域的?
希望不要出现如图的窗口。
前面加个减号 这样写行吗?版主能否帮我改一下?
'示例Boundary
Sub Boundary()<BR> Dim Pnt2 As Variant<BR> Pnt2 = ThisDrawing.Utility.GetPoint(, "选择点:")<BR> Dim lspPnt As String<BR> lspPnt = axPoint2lspPoint(Pnt2)<BR> ThisDrawing.SendCommand "-Boundary" & vbCr & lspPnt & vbCr<BR>End Sub
<BR>'转换双元表的函数
Public Function GetDoubleEntTable(entObj As AcadEntity, Pnt As Variant) As String<BR> Dim entHandle As String<BR> entHandle = entObj.Handle<BR> GetDoubleEntTable = "(list(handent " & Chr(34) & entHandle & Chr(34) & _<BR> ")(list " & Str(Pnt(0)) & Str(Pnt(1)) & Str(Pnt(2)) & "))"<BR>End Function
'转换点的函数
Public Function axPoint2lspPoint(Pnt As Variant) As String<BR> axPoint2lspPoint = Pnt(0) & "," & Pnt(1) & "," & Pnt(2)<BR>End Function
'转换图元函数
Public Function axEnt2lspEnt(entObj As AcadEntity) As String<BR> Dim entHandle As String<BR> entHandle = entObj.Handle<BR> axEnt2lspEnt = "(handent " & Chr(34) & entHandle & Chr(34) & ")"<BR>End Function<BR> Sub GetArea()<BR> Dim Pnt2 As Variant<BR> Pnt2 = ThisDrawing.Utility.GetPoint(, "选择点:")<BR> Dim lspPnt As String<BR> m = ThisDrawing.ModelSpace.Count<BR> ThisDrawing.SendCommand "-Boundary" & vbCr & "a" & vbCr & "o" & vbCr & "r" & vbCr & vbCr & Pnt2(0) & "," & Pnt2(1) & vbCr & vbCr<BR> n = ThisDrawing.ModelSpace.Count<BR> If m <> n Then<BR> MsgBox ThisDrawing.ModelSpace(n - 1).Area<BR> ThisDrawing.ModelSpace(n - 1).Delete<BR> Else<BR> MsgBox "Err"<BR> End If<BR>End Sub<BR>
页:
[1]