进来指点一二,谢谢
<P>我想计算铝型材的外顶点个数,我的想法是把所有图元形成面域,然后比较出最大的面域,统计出此面域的顶点一个,但是我觉得麻烦了点,形成面域后以后又要炸开,有没有更简单点的方法,请指点一二</P> 贴图说明一下 <P>不会发图片,呵呵</P> <P>?</P><P></P> <P>我编写了一段程序,不过好象有点问题</P>
<P>Sub point()<BR> Dim entcount As Integer<BR> <BR> Dim i As Integer<BR> <BR> Dim regcout As Integer<BR> Dim regionobj As Variant<BR> Dim outregion As AcadRegion<BR> <BR> Dim Selects As AcadSelectionSet<BR> Dim p As Integer<BR> ReDim entobj(0 To entcount - 1) As AcadEntity<BR> ReDim regions(0 To regcount - 1) As Variant<BR> entcount = ThisDrawing.ModelSpace.Count<BR> <BR> For i = 0 To entcount - 1<BR> Set entobj(i) = ThisDrawing.ModelSpace.Item(i) '将图上图元付给图元数组<BR> Next<BR> regionobj = ThisDrawing.ModelSpace.AddRegion(entobj) '将图元组合成区域<BR> For i = 0 To entcount - 1<BR> entobj(i).Delete<BR> Next<BR> regcount = ThisDrawing.ModelSpace.Count<BR> If regcount = 1 Then<BR> Set outregion = ThisDrawing.ModelSpace.Item(0)<BR> End If<BR> Do Until regcount = 1<BR> <BR> For i = 0 To regcount - 1<BR> Set regions(i) = ThisDrawing.ModelSpace.Item(i)<BR> Next<BR> Set outregion = regions(0)<BR> Loop<BR> For i = 1 To regcount - 1<BR> If regions(i).Area > outregion.Area Then<BR> Set outregion = regions(i)<BR> End If<BR> Next<BR> Selects.AddItems outregion<BR> For Each entity In Selects<BR> If UCase(entity.ObjectName) = "ACDBpoint" Then<BR> p = p + 1<BR> End If<BR> Next<BR> MsgBox p<BR> <BR>End Sub<BR></P> <P>你要获取的到底是什么?</P>
<P>是外部包装尺寸?</P> <P></P>
<P>就是要计算最外层的顶点的个数</P> 只要获得点的个数就可以了 <P>图里只有这些图元?</P>
<P>没有其它的?</P>
<P>不用选择么?</P> <P>注意AddRegion返回的是数组!</P>
<P>下面的函数利用AddRegion函数的返回值获取顶点数(和实体数相等)</P>
<P>Private Function GetPointCount(Regions As Variant)<BR>On Error Resume Next<BR> Dim pRegion As AcadRegion<BR> Dim i As AcadEntity<BR> <BR> '遍历面域数组找到最大面域<BR> For Each i In Regions<BR> If pRegion.Area < i.Area Then<BR> Set pRegion = i<BR> End If<BR> Next i<BR> <BR> objs = pRegion.Explode()<BR> GetPointCount = UBound(objs)<BR> <BR> For Each i In objs<BR> i.Delete<BR> Next i<BR> <BR>End Function<BR></P>
页:
[1]
2