BlockTable vs BlockTableRecord vs BlockReference

Top  Previous  Next

A BlockTable is a list of blocks.

 

A BlockTableRecord is a list of entities. The "main" block table record (block definition) is called "*MODEL_SPACE" and contains all the CAD entities in the drawing.

 

 

Block-Table-Stuff

 

A BlockReference corresponds to an "INSERT" in AutoCAD

 

You can get the main top level list of blocks in a drawing like this:

 

 

BlockTable MainBlockTable = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead);

 

This is how to get the model space block:

 

using (tr)

  {

    BlockTable bt = (BlockTable)tr.GetObject(db.BlockTableId,OpenMode.ForRead);

 

    BlockTableRecord btr = (BlockTableRecord)tr.GetObject(bt[BlockTableRecord.ModelSpace],OpenMode.ForWrite);

 

    // ...

 

  }