使用选择集删除数据之后的问题
在vba中,当使用选择集选择所有对象,然后调用erase和delete方法,在保存文件,此时文件应该非常小(20多k),但实际上保存的文件和原始文件一样大小,我想应该是选择集的问题,但应该怎么办呢?请大侠帮忙. 打开一个cad文件,重复执行下面代码,为什么c:\111.dwg文件会越来越大,应该怎么解决这个问题,使他不会增大,因为我想保证里面什么也没有,还有哪些对象,应该怎么删除。Dim SelectAll As AcadSelectionSet<BR> On Error GoTo Errorhandle<BR> If ThisDrawing.SelectionSets.Count > 0 Then<BR> For i = 0 To ThisDrawing.SelectionSets.Count - 1<BR> If LCase(ThisDrawing.SelectionSets.Item(i).Name) = "selectall" Then<BR> Set SelectAll = ThisDrawing.SelectionSets.Item(i)<BR> SelectAll.Delete<BR> End If<BR> Next<BR> End If<BR> <BR> Set SelectAll = ThisDrawing.SelectionSets.Add("selectall")<BR> SelectAll.Select AcSelect.acSelectionSetAll<BR> <BR> If (SelectAll.Count > 0) Then<BR> 'MsgBox SelectAll.Item(0).ObjectName<BR> SelectAll.Erase<BR> End If<BR> 'SelectAll.Delete<BR> ThisDrawing.SelectionSets.Item("selectall").Delete
ThisDrawing.SaveAs "C:\113" For i = 0 To ThisDrawing.SelectionSets.Count - 1<BR> If LCase(ThisDrawing.SelectionSets.Item(i).Name) = "selectall" Then<BR> Set SelectAll = ThisDrawing.SelectionSets.Item(i)<BR> SelectAll.Delete<BR> End If<BR>Next<BR>
在这个循环中,判断条件是选择集的个数,那么就不要再用ThisDrawing.SelectionSets.Item(i)了,把i改成0试试看。
页:
[1]