删除图层过滤器
我想删除图形中的所有现有图层过滤器。我这里的代码不起作用了…知道为什么吗_
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
**** Hidden Message ***** 它没有做什么?它只删除了1个过滤器,没有过滤器,崩溃等。
看看这个可能会有所帮助。
http://catb.org/~esr/faqs/smart-questions.html
页:
[1]