Click here to Skip to main content
15,799,186 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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")
            // code to read data from parts list


What I have tried:

I have tried the solution on these websites, but it applies to a different object.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900