上次发了关于选择集中删除元素的问题,得到了各位高手的指点,收益颇多。但是我在实际编制过程中发现一个问题,就是从选择集中删除的元素数组,似乎元素的个数不能太大我试验的结果似乎只能达到20000左右,再大了不是死机就是计算错误。看看下面的例子
Public Sub test() ThisDrawing.Application.ZoomExtents On Error Resume Next Dim SSet As AcadSelectionSet If Not IsNull(ThisDrawing.SelectionSets.Item("ttt")) Then Set SSet = ThisDrawing.SelectionSets.Item("ttt") SSet.Delete End If Set SSet = ThisDrawing.SelectionSets.Add("Example") Dim FilterType(0 To 3) As Integer Dim FilterData(0 To 3) As Variant FilterType(0) = -4 FilterData(0) = "<or" FilterType(1) = 0 FilterData(1) = "LINE" FilterType(2) = 0 FilterData(2) = "LWPOLYLINE" FilterType(3) = -4 FilterData(3) = "or>" SSet.Select acSelectionSetAll, , , FilterType, FilterData msgbox "筛选前的元素数量:"& SSet.Count Dim element As AcadEntity Dim i As Integer Dim pn1() As AcadEntity i = 0 For Each element In SSet If (element.Length > 200) Or (element.Length <100) Then i = i + 1 End If Next ReDim pn1(i - 1) As AcadEntity i = 0 For Each element In SSet If (element.Length > 200) Or (element.Length <100) Then Set pn1(i) = element i = i + 1 else element.color=acred End If Next SSet.RemoveItems pn1 SSet.Update msgbox "筛选剩余的元素数量:"& SSet.Count SSet.Delete end sub
这个程序试从图形中选择出所有直线和多线,然后从中删除长度大于200和小于100的元素。这样当 需要删除的对象删除的元素个数多到一定程度就会出问题。我初步设想可能是数组元素的限制问题。
请各位帮我看看能不能够在建立选择集的时候就直接只选择长度100~200之间的线???在此先行感谢了。。。 |