Remove Example

AEC Auto

Remove Example

Sub Example_Remove_LayerKeyStyle()

    ' This example adds a new layer key style to the layer key
    ' styles collection, then removes the new style.
  
    Dim app As New AecBaseApplication
    Dim doc As AecBaseDocument
    Dim layerkeystyles As AecLayerKeyStyles
    Dim layerkeystyle As AecLayerKeyStyle
    
    Dim msg As String
        
    ' Initialize.
    app.Init ThisDrawing.Application
    Set doc = app.ActiveDocument
       
    ' Get the layer key styles collection and note the number
    ' of objects in the collection.
    Set layerkeystyles = doc.layerkeystyles
    msg = "There were " & layerkeystyles.Count _
       & " layer key styles in this drawing." & vbCrLf

    ' Add a new layer key style to the collection.
    Set layerkeystyle = layerkeystyles.Add("ExampleStyle")
    layerkeystyle.Description = "This is a test"
  
    msg = msg & "After adding a layer key style, there are " _
       & layerkeystyles.Count & " of them."
    MsgBox msg, vbInformation, "Remove Example"

    ' Note the number of objects in the layer key styles collection now.
    msg = "The new layer key style had " & layerkeystyle.Keys.Count & " keys--" & vbCrLf

    ' Remove the layer key style that was just added.
    layerkeystyles.Remove ("ExampleStyle")
    
    msg = msg & "   but I've since removed the style..."
    MsgBox msg, vbInformation, "Remove Example"
  
End Sub