LayerExample

AEC Auto

Layer Example

Sub Example_Layer()

   ' This example lists the layer keys in the layer key style
   ' of the document's standard layer.

    Dim app As New AecBaseApplication
    Dim doc As AecBaseDocument
    Dim dbPref As AecBaseDatabasePreferences
    Dim cLayerKeyStyles As AecLayerKeyStyles
    Dim layerKeyStyle As AecLayerKeyStyle
    Dim cLayerKeys As AecLayerKeys
    Dim layerKey As AecLayerKey
    
    Dim msg As String
 
    ' Initialize the application object and access the current drawing.
    app.Init ThisDrawing.Application
    Set doc = app.ActiveDocument
    
    ' Get the drawing's collection of layer key styles.
    Set cLayerKeyStyles = doc.layerkeystyles

    ' Get the preferences object.
    Set dbPref = doc.Preferences
    
    ' Identify the layer standard.
    msg = "Layer standard is " & dbPref.LayerStandard _
       & ". It contains the following layer keys:" & vbCrLf
       
    ' Set the layer key style to the current layer standard.
    Set layerKeyStyle = cLayerKeyStyles.Item(dbPref.LayerStandard)
    
    ' Get the collection of layer keys in the style.
    Set cLayerKeys = layerKeyStyle.Keys
    
    ' Loop through the collection and list some properties of each key.
    For Each layerKey In cLayerKeys
        msg = msg & "   " & layerKey.Name & ":" & vbCrLf
        msg = msg & "     Color      - " & layerKey.Color & vbCrLf
        msg = msg & "     Layer      - " & layerKey.Layer & vbCrLf
        msg = msg & "     LineType   -  " & layerKey.Linetype & vbCrLf
        msg = msg & "     Lineweight - " & layerKey.Lineweight & vbCrLf
        msg = msg & "     Plotstyle  - " & layerKey.PlotStyleName & vbCrLf
    Next

   MsgBox msg, vbInformation, "Layer Example"
      
End Sub