Hi there,
I need to create a function that lists all the block in the drawing. I need the same list of blocknames when you go to the insert command and drop the combobox down to display the block in the block table.
My code works fine but when i have an dynamicblock it displays the wrong name. I know how to solve this for the blockreferences but i don't know how i can get the corresponding names from blocktable. I need the block to be in the list when it has no blockreference in the drawing.
Here's the code i use:
private void ListBlocks()
{
Database db = AutoCAD.DocumentManager.MdiActiveDocument.Database;
using (Transaction trans = db.TransactionManager.StartTransaction())
{
BlockTable bt = (BlockTable)trans.GetObject(db.BlockTableId, OpenMode.ForRead);
foreach (ObjectId bId in bt)
{
BlockTableRecord blkObj = (BlockTableRecord)trans.GetObject(bId, OpenMode.ForRead);
if (!blkObj.IsLayout)
{
cbbBlock.Items.Add(blkObj.Name);
}
}
}
}
Hope you guys can help me.
Kind regards,
Irvin