.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

List of Layer States

2 REPLIES 2
Reply
Message 1 of 3
flongsworth
478 Views, 2 Replies

List of Layer States

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.
2 REPLIES 2
Message 2 of 3
Anonymous
in reply to: flongsworth

Why not just use com interop and do it the same way as you would with VBA
Message 3 of 3
flongsworth
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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost