Hi All,
I seem to have fixed it, the table is a BlockTableRecord within the BlockTable....
This is what worked:
Code:
private static void Table_Locator()
{
Database db = HostApplicationServices.WorkingDatabase;
using (Transaction tr = db.TransactionManager.StartTransaction())
{
BlockTable bt1 = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead);
//Find the table
foreach (ObjectId objID in bt1)
{
BlockTableRecord bt2 = (BlockTableRecord)objID.GetObject(OpenMode.ForWrite);
ObjectIdCollection objIdColl = bt2.GetBlockReferenceIds(true, true);
foreach (ObjectId subObj in bt2)
{
if (subObj.ObjectClass.DxfName.ToUpper() == "ACAD_TABLE")
{
Table acTable = (Table)subObj.GetObject(OpenMode.ForWrite, true, true);
MgdAcApplication.DocumentManager.MdiActiveDocument.Editor.WriteMessage("Found: " + acTable.TableStyleName.ToUpper());
//if (acTable.TableStyleName.ToUpper() == "SampleStyle")
//{
// Set the cell content here
//}
}
}
}
tr.Commit();
}
}
Hope that helps anyone having the same trouble...