Kerry;
I was talking about on how to build the output list for autolisp, anyway I found it, here is (it is the same criteria when using arx):
[LispFunction("SummationR")]
public object summationr(ResultBuffer args)
{
ResultBuffer res = new ResultBuffer();
Document doc = acadApp.DocumentManager.MdiActiveDocument;
Editor ed = doc.Editor;
Dictionary<string, short> openWith = new Dictionary<string, short>();
IEnumerator it = args.GetEnumerator();
while (it.MoveNext())
{
short ad = 0, num = 0;
TypedValue val = (TypedValue)it.Current;
if ((LispDataType)val.TypeCode != LispDataType.ListBegin && (LispDataType)val.TypeCode != LispDataType.ListEnd)
{
string sKey = val.Value.ToString();
it.MoveNext();
val = (TypedValue)it.Current;
num = (short)val.Value;
try
{
openWith.Add(sKey, num);
}
catch (ArgumentException)
{
if (openWith.TryGetValue(sKey, out ad))
{
num = (short)(num + ad);
openWith.Remove(sKey);
openWith.Add(sKey, num);
}
}
}
}
res.Add(new TypedValue((int)LispDataType.ListBegin, -1)); // open the main list "("
foreach (KeyValuePair<string, short> kvp in openWith)
{
res.Add(new TypedValue((int)LispDataType.ListBegin, -1)); // open a list "("
res.Add(new TypedValue((short)LispDataType.Text, kvp.Key)); // add the key "str"
res.Add(new TypedValue((short)LispDataType.Int16, kvp.Value)); // add the value 'short'
res.Add(new TypedValue((int)LispDataType.ListEnd, -1)); // close the list ")"
}
res.Add(new TypedValue((int)LispDataType.ListEnd, -1)); // close the main list ")"
return res;
}