我想删除图形中的所有现有图层过滤器。我这里的代码不起作用了…知道为什么吗
- _
- Public Sub CreateDeleteFilters()
- Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument
- Dim acCurDb As Database = acDoc.Database
- Dim acEditor As Editor = acDoc.Editor
- Try
- ' Get the existing layer filters
- ' (we will add to them and set them back)
- Dim MyLayerFilterTree As LayerFilterTree = acCurDb.LayerFilters
- Dim MyLayerFilterCollections As LayerFilterCollection = MyLayerFilterTree.Root.NestedFilters
- ' Prompt for the index of the filter to delete
- For i As Integer = 0 To MyLayerFilterCollections.Count - 1
- ' Get the selected filter
- Dim MyLayerFilter As Autodesk.AutoCAD.LayerManager.LayerFilter = _
- MyLayerFilterCollections(i)
- ' If it's possible to delete it, do so
- Select Case MyLayerFilter.AllowDelete
- Case False
- acEditor.WriteMessage(vbLf & "Layer filter cannot be deleted.")
- Case True
- MyLayerFilterCollections.Remove(MyLayerFilter)
- acCurDb.LayerFilters = MyLayerFilterTree
- End Select
- Next
- Catch ex As Exception
- acEditor.WriteMessage(vbLf & "Exception: {0}", ex.Message)
- End Try
- End Sub
本帖以下内容被隐藏保护;需要你回复后,才能看到! 游客,如果您要查看本帖隐藏内容请 回复 |