.NET

Reply
Contributor
flongsworth
Posts: 17
Registered: ‎01-27-2005
Message 1 of 3 (160 Views)

List of Layer States

160 Views, 2 Replies
01-28-2006 09:45 PM
Somebody!. How can I simply get a list of the Existing Layer States in a dwg. It's pretty simple to do in VBA, just get the "ACAD_LAYERSTATES" dictionary and get the name property of each Xrecord. What is the .net equivalent.
*Mark Gardiner
Message 2 of 3 (160 Views)

Re: List of Layer States

02-01-2006 05:25 PM in reply to: flongsworth
Why not just use com interop and do it the same way as you would with VBA
Contributor
flongsworth
Posts: 17
Registered: ‎01-27-2005
Message 3 of 3 (160 Views)

Re: List of Layer States

02-01-2006 06:33 PM in reply to: flongsworth
Yes, you are absolutely right. Here is the code that worked for me just in case somebody runs across the same issue. Thanks again Mark!
I hope the copy and paste works ok, though

Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.LayerManager
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.Colors
Imports Autodesk.AutoCAD.Geometry
Imports Autodesk.AutoCAD.GraphicsInterface
Imports System.Runtime.InteropServices
Imports Autodesk.AutoCAD.Interop
Imports Autodesk.AutoCAD.Interop.Common
Imports AcadCOMintf = Autodesk.AutoCAD.ApplicationServices.Application

Inherits System.Windows.Forms.Form
Public AcadApp As AcadApplication
Public AcadDoc As AcadDocument
Public Shared oAcadCOMApp As Autodesk.AutoCAD.Interop.AcadApplication = CType(AcadCOMintf.AcadApplication, AcadApplication)

Private Sub ListLayerStates()

Try
Dim oAcadCOMDoc As Autodesk.AutoCAD.Interop.AcadDocument
oAcadCOMDoc = oAcadCOMApp.ActiveDocument

Dim lsDict As AcadDictionary = oAcadCOMDoc.Layers.GetExtensionDictionary.Item("ACAD_LAYERSTATES")
Dim Xrec As AcadXRecord
For Each Xrec In lsDict
lstLayerStates.Items.Add(Xrec.Name)
Next
Catch acadex As Autodesk.AutoCAD.Runtime.Exception
MsgBox(acadex.Message)
End Try


End Sub
Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.