Community
// Get Block Table and Block Table Record} Edited by: Arrowstick on Nov 12, 2008 3:24 PM
BlockTable bt = (BlockTable)trans.GetObject(db.BlockTableId, OpenMode.ForRead);
BlockTableRecord btrMS = (BlockTableRecord)trans.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForRead);
// Now iterate through ModelSpace (means through btrMS)
foreach (ObjectId id in btrMS)
{
// Fetch the entity
Entity ent = (Entity)trans.GetObject(id, OpenMode.ForRead, false);
// Test if the entity is a BlockReference
if (ent.GetType() == typeof(BlockReference))
{
// It's a BlockReference... cast it:
BlockReference blRef = (BlockReference)ent;
// Now you can acces attributes via the AttributeCollection
// Do Something with:
blRef.AttributeCollection;
}
}
// commit Transaction
trans.Commit();
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
"Arrowstick" wrote in messageI'm
href="news:6070458@discussion.autodesk.com">news:6070458@discussion.autodesk.com...
not sure, if you still need it, but this is a possible way:
// get the
working database
Database db = HostApplicationServices.WorkingDatabase;
// Start a transaction.
using (Transaction trans =
db.TransactionManager.StartTransaction())
{
// Get Block Table and Block Table Record} Edited by: Arrowstick on Nov 12, 2008
BlockTable bt =
(BlockTable)trans.GetObject(db.BlockTableId, OpenMode.ForRead);
BlockTableRecord btrMS =
(BlockTableRecord)trans.GetObject(bt[BlockTableRecord.ModelSpace],
OpenMode.ForRead);
// Now iterate through ModelSpace (means through
btrMS)
foreach (ObjectId id in btrMS)
{
// Fetch the entity
Entity ent = (Entity)trans.GetObject(id, OpenMode.ForRead, false);
//
Test if the entity is a BlockReference
if (ent.GetType() ==
typeof(BlockReference))
{
// It's a BlockReference... cast it:
BlockReference blRef = (BlockReference)ent;
// Now you can acces
attributes via the AttributeCollection
// Do Something with:
blRef.AttributeCollection;
}
}
// commit Transaction
trans.Commit();
3:24 PM