• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    .NET

    Reply
    Active Contributor
    Posts: 43
    Registered: ‎04-21-2005

    .net cannot do Conditional Filtering!!

    96 Views, 6 Replies
    05-30-2005 05:30 AM
    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?
    Please use plain text.
    *Albert Szilvasy

    Re: .net cannot do Conditional Filtering!!

    05-30-2005 01:28 PM 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?
    Please use plain text.
    *Tony Tanzillo

    Re: .net cannot do Conditional Filtering!!

    05-31-2005 01:44 AM 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
    Please use plain text.
    *Albert Szilvasy

    Re: .net cannot do Conditional Filtering!!

    05-31-2005 09:39 AM 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
    Please use plain text.
    Active Contributor
    Posts: 43
    Registered: ‎04-21-2005

    Re: .net cannot do Conditional Filtering!!

    06-01-2005 11:38 PM 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?
    Please use plain text.
    *Tony Tanzillo

    Re: .net cannot do Conditional Filtering!!

    06-03-2005 01:08 AM 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?
    Please use plain text.
    Active Member
    Posts: 6
    Registered: ‎09-18-2005

    Re: .net cannot do Conditional Filtering!!

    09-25-2005 09:11 AM 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 ?
    Please use plain text.