Hello!
Iīm not sure I do it right from beginning, I would like read many Drawings with db.ReadDwgFile(filename, System.IO.FileShare.Read, true, ""); and get all block with name "stamp" on different Layouts in these Drawings. The block stamp have attributes I want read/write. My problem is this:
using (Transaction tr = db.TransactionManager.StartTransaction())
{
BlockTable bt =
(BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead);
if (bt.Has(blockname))
{
BlockTableRecord btr =
(BlockTableRecord)tr.GetObject(bt[blockname], OpenMode.ForRead);
foreach (ObjectId refId in btr.GetBlockReferenceIds(true, false))
the method GetBlockReferenceIds give me 13 objects, I understand 13 objects founds with name "stamp". But when I look in the attributs from refId
foreach (ObjectId refId in btr.GetBlockReferenceIds(true, false))
{
BlockReference br = (BlockReference)tr.GetObject(refId, OpenMode.ForRead);
ent = AcDbExtensionMethods.GetAttributesToDictionaryKeyByTag(br);
result.Add(ent);
}
public static Dictionary<string, DBText> GetAttributesToDictionaryKeyByTag(this BlockReference blockref)
{
return blockref.GetAttributes().ToDictionary(a => GetTag(a), StringComparer.OrdinalIgnoreCase);
}
I get always the same blockattributesvalues but different ObjectIds how can that be ?
My work I will do to read these Drawing with block "stamp" and could change values and save them, thanks for your support!