Instead of
List<object[]>
i'd use a
Dictionary[
^].
Dictionary<string, int> myCounter = new Dictionary<string, int>();
using (var tr = db.TransactionManager.StartTransaction())
{
foreach (SelectedObject so in psr.Value)
{
BlockReference bref = (BlockReference)tr.GetObject(so.ObjectId, OpenMode.ForRead);
Autodesk.AutoCAD.DatabaseServices.AttributeCollection attcoll = bref.AttributeCollection;
foreach (ObjectId id in attcoll)
{
AttributeReference atref = (AttributeReference)tr.GetObject(id, OpenMode.ForRead);
if (atref.Tag.Contains("ROOM"))
if (!myCounter.ContainsKey(atref.TextString))
{
myCounter.Add(atref.TextString, 1);
}
else
{
myCounter[atref.TextString] += 1;
}
}
}
}
Console.WriteLine("Key | Count");
foreach(var k in myCounter.Keys)
{
Console.WriteLine("{0} | {1}", k, myCounter[k]);
}
Above code should return something like this:
Key | Count
ROOM | 5
ROOMID | 10
ROOMAREA | 15