.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

.net cannot do Conditional Filtering!!

6 REPLIES 6
Reply
Message 1 of 7
tangferry
345 Views, 6 Replies

.net cannot do Conditional Filtering!!

In objectarx(C++) ,You can use the following code selects all circles in the drawing with a radius of 1.0 and all lines on the layer "ABC".

struct resbuf* prb;
prb=acutBuildList(-4,"",-4,"",-4,"or>",0);
acedSSGet("X",NULL,NULL,prb,ssname);
But how to do this in .net?
6 REPLIES 6
Message 2 of 7
Anonymous
in reply to: tangferry

You can't. This is a bug. The managed wrapper is interpreting -4
incorrectly. The internal bug number is 646182 in case you ever want to
inquire its status through official support channels.

Albert
wrote in message news:4859917@discussion.autodesk.com...
In objectarx(C++) ,You can use the following code selects all circles in the
drawing with a radius of 1.0 and all lines on the layer "ABC".

struct resbuf* prb;
prb=acutBuildList(-4,"",-4,"",-4,"or>",0);
acedSSGet("X",NULL,NULL,prb,ssname);
But how to do this in .net?
Message 3 of 7
Anonymous
in reply to: tangferry

"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
Message 4 of 7
Anonymous
in reply to: tangferry

Indeed, the fix will involve fixing acdbGroupCodeToType() so that it works
properly for resbuf chains that specify a selection filter. The type codes
in a resbuf chain should be unambiguous irregardless of the usage of the
resbuf chain.

Albert

"Tony Tanzillo" wrote in message
news:4860355@discussion.autodesk.com...
"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
Message 5 of 7
tangferry
in reply to: tangferry

hi,Tony Tanzillo.Thanks for your reply.
But your code does not work,can you give a full example?Or can you give an example for using the acutBuildList in C# through the unmanaged codes.
Here is my code(but it does not work),can you exam it?
Message 6 of 7
Anonymous
in reply to: tangferry

wrote

> hi,Tony Tanzillo.Thanks for your reply.
> But your code does not work

It certainly does work. If it does not work for
you, it is because you are doing something wrong.

Are you expecting me to guess what that is?

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com

,can you give a full example?Or can you give an example for using the acutBuildList in C# through the unmanaged codes.
Here is my code(but it does not work),can you exam it?
Message 7 of 7
emilg
in reply to: tangferry

This code is very interesting to me. It is exactly what I am finding. I took it BUT it doesn't work ???

But am sure that it works at you.
I have only one idea. What do you think about this.
I am using Visual Studio 2003, and all may managed code works fine. May be problem that unmanaged code I may to use only in Visual Studio 2002 ?

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost