9 For k = 0 To SelectionSet.Count - 1 If (你的条件) Then ReDim deleteObj(0) As Object Set deleteObj(0) = SelectionSet.Item(k) SelectionSet.RemoveItems deleteObj GoTo 9 End If Next
Sub RemoveSsetsObjects()
' ´ÓÑ¡Ôñ¼¯ÖÐÒƳý¶ÔÏó
On Error Resume Next
Dim sset As AcadSelectionSet
Set sset = ThisDrawing.SelectionSets.Add("SS4")
sset.SelectOnScreen
MsgBox sset.Count
Dim Ent As AcadObject
Dim deleteObj() As Object
k = 0
For Each Ent In sset
If Ent.Layer = "0" Then
ReDim Preserve deleteObj(k) 'As Object
Set deleteObj(k) = Ent
k = k + 1
End If
Next
sset.RemoveItems deleteObj
MsgBox sset.Count
sset.Delete
End Sub