/// <summary>
/// Updates the attributes.
/// </summary>
/// <param name="blockRefID">The block reference objectID.</param>
/// <param name="atts">Dictionary where the key is the tag, the value the textstring</param>
public static int UpdateAttributes(ObjectId blockRefID, Dictionary<string, string> atts)
{
int updatedAtts = 0;
using (LockedTransaction acTr = Active.Document.TransactionManager.StartLockedTransaction())
{
BlockReference blockRef = acTr.GetObject(blockRefID, OpenMode.ForRead,true) as BlockReference;
if (blockRef!=null)
{
foreach (KeyValuePair<string, string> att in atts)
{
foreach (ObjectId attId in blockRef.AttributeCollection)
{
AttributeReference ar = acTr.GetObject(attId, OpenMode.ForRead) as AttributeReference;
if (ar != null && string.Equals(ar.Tag, att.Key, StringComparison.CurrentCultureIgnoreCase))
{
ar.UpgradeOpen();
ar.TextString = att.Value;
ar.DowngradeOpen();
updatedAtts++;
}
}
}
}
acTr.Commit();
}
return updatedAtts;
}