计算图斑面积时的岛
<P>我用SelectByPolygon方法进行选择时总是不能选到与边界相连的内部多边形(图形见付件),我在开发论坛问了一个月了也没人回答,希望这里能得到帮助,先谢谢</P><P>Sub selectPl()<BR> Dim ent As AcadEntity<BR> Dim SelObj As AcadEntity<BR> Dim NumSel As Integer<BR> Dim Coord As Variant<BR> Dim CoordCount As Integer<BR> Dim NewCoord() As Double<BR> Dim i As Integer<BR> <BR> Dim ssetObj As AcadSelectionSet<BR> On Error GoTo Err1:<BR> Set ssetObj = ThisDrawing.SelectionSets.Add("TEST_SSET2")<BR> <BR> On Error Resume Next<BR> Do<BR> ThisDrawing.Utility.GetEntity ent, pnt, "选择多段线:"<BR> If Err Then Exit Sub<BR> If TypeName(ent) Like "IAcad*Polyline" Then Exit Do<BR> Loop<BR> <BR>If TypeName(ent) = "IAcadLWPolyline" Then<BR> Coord = ent.Coordinates </P>
<P> CoordCount = (UBound(Coord) + 1) / 2 '顶点数<BR> '定义新的顶点坐标数组<BR> ReDim NewCoord(0 To (3 * CoordCount - 1)) As Double<BR> For i = 0 To UBound(Coord) - 1 Step 2<BR> NewCoord((3 * i) / 2) = Coord(i)<BR> NewCoord((3 * i) / 2 + 1) = Coord(i + 1)<BR> NewCoord((3 * i) / 2 + 2) = 0<BR> Next i<BR>ElseIf TypeName(ent) = "IAcadPolyline" Then<BR> Coord = ent.Coordinates<BR> CoordCount = (UBound(Coord) + 1) / 3<BR> ReDim NewCoord(0 To UBound(Coord)) As Double<BR> For i = 0 To UBound(Coord) - 1<BR> NewCoord(i) = Coord(i)<BR> NewCoord(i) = Coord(i)<BR> NewCoord(i) = Coord(i)<BR> Next</P>
<P>End If<BR>ssetObj.SelectByPolygon acSelectionSetWindowPolygon, NewCoord<BR>ssetObj.Highlight True<BR>ssetObj.Update<BR>NumSel = ssetObj.Count<BR>Exit Sub<BR>Err1:<BR> ThisDrawing.SelectionSets.Item("TEST_SSET2").Delete<BR> Resume<BR>End Sub</P> 刚才没把付件搞上 谢谢分享,不错
页:
[1]