Author Topic: List Layers LISTBOX  (Read 1690 times)

0 Members and 1 Guest are viewing this topic.


  • Newt
  • Posts: 130
List Layers LISTBOX
« on: September 14, 2012, 08:52:07 PM »
how to list the layers in the drawing to be displayed in a LISTBOX?


  • King Gator
  • Posts: 3742
Re: List Layers LISTBOX
« Reply #1 on: September 15, 2012, 01:08:34 AM »
Perhaps this thread will be of use:
"Potential has a shelf life." - Margaret Atwood


  • Guest
Re: List Layers LISTBOX
« Reply #2 on: September 15, 2012, 08:51:20 AM »
Try this code snip from my old code

Code: [Select]
     Public Class Form1

    Private listOfLayers As New List(Of String)

    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        Dim docs As DocumentCollection = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager
        Dim doc As Document = docs.MdiActiveDocument
        Dim db As Database = doc.Database
        Dim ed As Editor = doc.Editor
        Using tr As Transaction = doc.TransactionManager.StartTransaction
            Dim lt As LayerTable = DirectCast(tr.GetObject(db.LayerTableId, OpenMode.ForRead, False), LayerTable)
            For Each lid As ObjectId In lt

                Dim ltr As LayerTableRecord = tr.GetObject(lid, OpenMode.ForRead)
                If lid.IsValid Then
                End If
        End Using
        Me.lstLayers.DataSource = listOfLayers
    End Sub

I've used modeless form, so change to your suit, say
avoid to load xreferenced layers etc



  • Newt
  • Posts: 130
Re: List Layers LISTBOX
« Reply #3 on: September 18, 2012, 09:37:25 PM »
Fixed (Oleg) thank me for having collaborated once again. When you want to know the wonderful city (Rio de Janeiro-BR) I have great pleasure to welcome you in my apartment.


  • Guest
Re: List Layers LISTBOX
« Reply #4 on: September 19, 2012, 01:15:21 AM »
You're welcome,
Glad I could help
Happy coding,