I need to update a block Insert's attributes from a selection set of dimensions.
Have this little test method that accepts the matching tag property and the textstring value.
It works okay, except the block reference does not get updated....
Any Ideas why the transaction.Commit() is not doing anything?
private void ModifyBlockAtt(string dimNo, string sValue)
{
// already have db and ed defined
Transaction tr;
TypedValue[] filterlist;
Autodesk.AutoCAD.EditorInput.SelectionFilter filter;
Autodesk.AutoCAD.EditorInput.PromptSelectionResult selRes;
Autodesk.AutoCAD.EditorInput.SelectionSet oSS = null;
using(tr = db.TransactionManager.StartTransaction())
{
filterlist = new TypedValue[2];
filterlist[0] = new TypedValue(0, "INSERT");
filterlist[1] = new TypedValue(2, "CrimperDataInputTable");
filter = new SelectionFilter(filterlist);
selRes = ed.SelectAll(filter);
if (selRes.Status != Autodesk.AutoCAD.EditorInput.PromptStatus.OK)
{
ed.WriteMessage("\nNo Table Block in the drawing ");
return;
}
oSS = selRes.Value;
BlockReference oEnt;
oEnt = (BlockReference)tr.GetObject(oSS[0].ObjectId, OpenMode.ForRead);
for (int i = 0; i < oEnt.AttributeCollection.Count; i++)
{
ObjectId id = oEnt.AttributeCollection[i];
AttributeReference aRef = (AttributeReference)tr.GetObject(id, OpenMode.ForWrite);
if (aRef.Tag == dimNo)
{
aRef.TextString = sValue;
tr.Commit();
return;
}
}
}
}
Thanks