(1)
Private Sub UserForm_Initialize() '清空选择集合中已有的选择集。避免重名 Dim objSset As AcadSelectionSet Dim Intstep As Integer If ThisDrawing.SelectionSets.count <> 0 Then For Each objSset In ThisDrawing.SelectionSets objSset.Delete Next objSset End If End Sub
(2) Private Sub UserForm_Initialize() '清空选择集合中已有的选择集。避免重名 Dim objSset As AcadSelectionSet Dim Intstep As Integer If ThisDrawing.SelectionSets.count <> 0 Then For Intstep = 0 To (ThisDrawing.SelectionSets.count - 1) Set objSset = ThisDrawing.SelectionSets.Item(Intstep) objSset.Delete Next End If End Sub
我用的事AutoCAD2004
当我用第一种方法的时候,如果有选择集存在(即selectionsets.count<>0)就会只删除选择集(selectionset)到剩余最后一个,然后再往选择集(selectionsets)内添加重名的选择集(selectionset)时,系统就会报错,而且关掉了autocad的界面.
用第二种方法时就一切ok
哪位高手指点一下是为什么??? |