打开一个cad文件,重复执行下面代码,为什么c:\111.dwg文件会越来越大,应该怎么解决这个问题,使他不会增大,因为我想保证里面什么也没有,还有哪些对象,应该怎么删除。
Dim SelectAll As AcadSelectionSet On Error GoTo Errorhandle If ThisDrawing.SelectionSets.Count > 0 Then For i = 0 To ThisDrawing.SelectionSets.Count - 1 If LCase(ThisDrawing.SelectionSets.Item(i).Name) = "selectall" Then Set SelectAll = ThisDrawing.SelectionSets.Item(i) SelectAll.Delete End If Next End If
Set SelectAll = ThisDrawing.SelectionSets.Add("selectall") SelectAll.Select AcSelect.acSelectionSetAll
If (SelectAll.Count > 0) Then 'MsgBox SelectAll.Item(0).ObjectName SelectAll.Erase End If 'SelectAll.Delete ThisDrawing.SelectionSets.Item("selectall").Delete
ThisDrawing.SaveAs "C:\113"
For i = 0 To ThisDrawing.SelectionSets.Count - 1 If LCase(ThisDrawing.SelectionSets.Item(i).Name) = "selectall" Then Set SelectAll = ThisDrawing.SelectionSets.Item(i) SelectAll.Delete End If Next
在这个循环中,判断条件是选择集的个数,那么就不要再用ThisDrawing.SelectionSets.Item(i)了,把i改成0试试看。