Click here to Skip to main content
15,885,914 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.

C#
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.

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
Posted

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