View Full Version : Extracting Block Information
2008-12-02, 09:30 AM
I'm working on a .NET C# Windows app for automatically indexing drawings, I need to extract titles and drawing numbers from blocks on drawings. (our drawings have been built with templates which contain meaningful blocks).
Doesn't anyone have a headstart on this before I spend days getting my head round the API?
2008-12-02, 04:47 PM
I have only worked with .Net within Acad, so I'm not sure how to connect and that stuff from windows, but once you get into the drawing you search the BlockTable to see if the blocks exists in the drawing, and once you know they do, the BlockTableRecord has a method to get all the inserted blocks ( BlockReference ), GetBlockReferenceIds. Once you get that, then you can get the AttributeCollection from the BlockReference, and get all the information you need.
2008-12-15, 10:36 PM
Kean Wamsley gives some good insight on working with blocks here
I believe there is a way to use possibly RealDWG or a different way to access block information without opening the actual drawing.
Other than that....here is a way to start autocad and open a drawing from an outside program
Autodesk.AutoCAD.Interop.AcadApplication acadApplication = new Autodesk.AutoCAD.Interop.AcadApplication;
acadDrawing = acadApplication.Documents.Open(<pathname>, true, paramMissing);
Make sure you also close your drawings and kill the application when you are done or you will get some dreaded HRResult error
if (acadDrawing != null)
acadDrawing = null;
Process aCAD = Process.GetProcessesByName("acad");
foreach (Process aCADPro in aCAD)
make sure you reference acdbmgd.dll and acmgd.dll from your AutoCAD root folder
To open a file and access the block table, use the Database.ReadDwgFile() method.
2008-12-17, 12:51 AM
AutoCAD 2007,2008,2009 folders contain a AcDx.dll
which contains the namespace Autodesk.AutoCAD.DataExtraction
.. that may be of use.
Powered by vBulletin® Version 4.1.11 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.