"Albert Szilvasy" wrote
>> You can't. This is a bug. The managed wrapper is
>> interpreting -4 incorrectly.
Looks like the problem is that ResultBuffer is using
acdbGroupCodeToType (in ResbufToTypedValue and
TypedValueToResbuf), which is fine for xdata and
xrecord lists, but is not for selection set filter lists
(never was). Not sure what the designer was thinking
there
🙂
Given the problem, I'd guess that an interim fix for
the current release is unlikely.
But the good news is that a workaround (involving
a bit of unsafe code) is fairly simple:
////////// Requires /unsafe compiler switch
unsafe private struct resbuf_thunk
{
internal resbuf_thunk* rbnext;
internal short restype;
internal void* resval;
};
unsafe private void
AddStringToResbuf(ResultBuffer buffer, short rtype, string val)
{
const short RTSTR = 5005;
buffer.Add( new TypedValue( RTSTR, val ));
resbuf_thunk* rb = (resbuf_thunk*) buffer.UnmanagedObject.ToPointer();
resbuf_thunk* tail = null;
while( rb != null )
{
tail = rb;
rb = rb->rbnext;
}
if( tail != null )
tail->restype = rtype;
}
// with the above, he can do the same as this
//
// acutBuildList(-4,"
")
//
// like this:
{
const short RTDXF0 = 5020;
ResultBuffer myFilter = new ResultBuffer();
AddStringToResbuf(myFilter, -4, "
myFilter.Add( new TypedValue(RTDXF0, "CIRCLE"));
myFilter.Add( new TypedValue(40, 1.0));
AddStringToResbuf(myFilter, -4, "AND>");
}
if ResultBuffer does not like RTDXF0 (not sure, haven't
tested this), AddString() should be useful for working
around that as well.
There is one caveat, which is that once a ResultBuffer has
been hacked this way, we can't iterate over it; call the
AsArray() member; or do anything else that renders the
contents of the ResultBuffer as TypedValues, because that
also leads to a call to acdbGroupCodeToType().
--
http://www.caddzone.com
AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com