I am trying to write a command that will extract the Bill of materials data out of an Autocad Mechanical drawing. It can be done in Autocad Mechanica , but I'd like to automate it.
[
Link on how to do it in Autocad]
The code extract below finds the Parts List object (a table of the bill of materials), but I cannot find how to extract its data.
The ACMPARTLIST looks like a table, but it cannot be extracted using the autocad command TableExport, or DataExtraction.
DBObjectCollection objs = new DBObjectCollection();
Document doc = AcadApp.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
Editor ed = doc.Editor;
ObjectId Id;
using (Transaction tr = db.TransactionManager.StartTransaction())
{
BlockTable bt;
bt = tr.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable;
BlockTableRecord btr;
btr = tr.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForRead) as BlockTableRecord;
ObjectIdCollection ids = new ObjectIdCollection();
foreach (ObjectId id in btr)
{
if (id.ObjectClass.DxfName == "ACMPARTLIST")
{
}
}
}
What I have tried:
I have tried the solution on these websites, but it applies to a different object.
http://forums.autodesk.com/t5/net/extracting-bom-from-autocad-using-c/td-p/3873852
http://forums.augi.com/showthread.php?136467-lisp-table-help&p=1167872&viewfull=1#post1167872