请问高手,程序错在哪里?
'*****************************************************<BR>'功能:求得所有相同层的面积<BR>'参数1:<BR>'参数2:<BR>'参数2:<BR>'返回:面积<BR>'*****************************************************Public Function MulLayerArea() As Double<BR> Dim PointObj As AcadPoint '用户获得的实体上任意一点<BR> Dim Ps As Variant '用户获得的任意一点坐标<BR> Dim LayerName As AcadLayer '用户获得的坐标点图层<BR> Dim SpaceCount As Long<BR> Dim n As Integer<BR> Dim EntityObj As AcadEntity '遍历的实体<BR> Dim RegionObj As Variant '创建所有具有相同层的面域<BR> Dim AllLayerArea As Double '所有相同层的面积<BR> AllLayerArea = 0<BR> Ps = ThisDrawing.Utility.GetPoint(, "指定内部点")<BR> Set PointObj = ThisDrawing.ModelSpace.AddPoint(Ps)<BR> 'LayerName = PointObj.Layer<BR> For Each EntityObj In ThisDrawing.ModelSpace<BR> 'Set EntityObj = ThisDrawing.ModelSpace.Item(n)<BR> If EntityObj.Layer = PointObj.Layer Then<BR> RegionObj = ThisDrawing.ModelSpace.AddRegion(EntityObj)<BR> AllLayerArea = AllLayerArea + RegionObj.Area<BR> End If<BR> Next EntityObj<BR> MsgBox AllLayerArea<BR>End Function
望赐教! 1、EntityObj必须是能构成面域的对象,闭合是必要条件。
2、AddRegion返回的是对象数组,而不是单一实体。 谢谢斑竹的赐教!我还想请教几点:
1、如何判断EntityObj是闭合的?
2、由<b>EntityObj如何得出数组?</b>
<b>可否帮我修改以上程序!</b>
页:
[1]