Is this possible? I was trying to make a simple windows program that prompted the user to select a .dwg file and the program would list all the layers in a listbox. But the Database.ReadDWGFile procedure doesn't appear to work outside of AutoCAD (FileNotFound Exception). Can I have my windows program open AutoCAD in the background to achieve this?
Here's my code:
Imports Autodesk.AutoCAD.Runtime Imports Autodesk.AutoCAD.ApplicationServices Imports Autodesk.AutoCAD.DatabaseServices Imports Autodesk.AutoCAD.EditorInput Public Class Form1 Dim myLayers As ArrayList Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim myDB As New Database(False, True) myDB.ReadDwgFile("C:\test.dwg", FileOpenMode.OpenForReadAndAllShare, True, "") Using myTrans As Transaction = myDB.TransactionManager.StartTransaction Dim myLayerTable As LayerTable = myDB.LayerTableId.GetObject(OpenMode.ForRead) Dim layerName As String = "" For Each myObjectID As ObjectId In myLayerTable Dim myLayer As LayerTableRecord = myObjectID.GetObject(OpenMode.ForRead) myLayers.Add(myLayer.Name) Next myTrans.Abort() End Using myDB.Dispose() For Each layerxx In myLayers ListBox1.Items.Add(layerxx) Next End Sub End Class
Solved! Go to Solution.
Solved! by AlexanderRivilis. See the answer in context.
Is this possible?
But the Database.ReadDWGFile procedure doesn't appear to work outside of AutoCAD
You can only use ActiveX interface of AutoCAD from external application, e.g.
You can use either AutoDesk RealDWG
or Teigha™.NET for .dwg files
To modify files without Autocad.
These are both pay options.
The only free options is to have Autocad Installed and use ActiveX.
Access a broad range of knowledge to help get the most out of your products and services.
Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.
Upgrading to a 2015 product? Make sure to check these out 1st!