- Sub test()
- On Error Resume Next
- '创建选择集
- Dim SSetObj As Object
- Set SSetObj = ThisDrawing.SelectionSets("LayerCount")
- If Err.Number <> 0 Then
- Err.Clear
- Set SSetObj = ThisDrawing.SelectionSets.Add("LayerCount")
- End If
- SSetObj.Clear
-
- On Error GoTo ErrTrap
- '创建过滤机制
- Dim fType(0 To 0) As Integer
- Dim fData(0 To 0) As Variant
- fType(0) = 8: fData(0) = "0" ' 层名
-
- '选择0层的所有实体
- SSetObj.Select acSelectionSetAll, , , fType, fData
-
- '返回0层的实体数目
- Debug.Print SSetObj.Count
-
- '删除数组
- Erase fType: Erase fData
-
- '删除选择集
- SSetObj.Clear
- SSetObj.Delete
- Set SSetObj = Nothing
- Exit Sub
-
- ErrTrap:
- MsgBox "出错了,请检查程序!"
- On Error GoTo 0
- End Sub
|