TheSwamp
Code Red => .NET => Topic started by: FELIX on September 14, 2012, 08:52:07 PM
-
how to list the layers in the drawing to be displayed in a LISTBOX?
-
Perhaps this thread will be of use:
http://www.theswamp.org/index.php?topic=42148.0
-
Try this code snip from my old code
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
listOfLayers.Add(ltr.Name)
End If
Next
tr.Commit()
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
~'J'~
-
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.
OK.
-
You're welcome,
Glad I could help
Happy coding,
Oleg