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

    .NET

    Reply
    Active Contributor
    Posts: 34
    Registered: ‎11-28-2012
    Accepted Solution

    Next object in scan

    88 Views, 4 Replies
    01-09-2013 12:26 AM

    Is there a way to get the next object in the dwg file when I know the object id of an object?

     

    foreach(ObjectId oid in blockTableRecord)

    {

        // Check next object(using next oid)

        // Do something using oid

    }

     

    Please use plain text.
    *Expert Elite*
    Posts: 6,455
    Registered: ‎06-29-2007

    Re: Next object in scan

    01-09-2013 12:49 AM in reply to: Fredrik.Larsen

    Hi,

     

    why not modifying your loop in that way:

     

       declare previousObj

       declare currentObj

       foreach(ObjectId oid in blockTableRecord)

       {

           // if previousObj defined (so to step over if it's the first object in queue and continue with loop2/object2)

           // {

                 // get currentObj

                 // check currentObj

                 // do something with previousObj

                 // save currentObj as previouObj for the next loop

           // }
      }

     

     

    Another option might be to first scan through the BlockTableRecord and gather the ObjectIDs into a collection (or any type of list/array that can be accessed by an index).

     

     

    - alfred -

    -------------------------------------------------------------------------
    Alfred NESWADBA
    Ingenieur Studio HOLLAUS ... www.hollaus.at
    -------------------------------------------------------------------------
    Please use plain text.
    Active Contributor
    Posts: 34
    Registered: ‎11-28-2012

    Re: Next object in scan

    01-09-2013 04:31 AM in reply to: alfred.neswadba

    Yeah, i figured I posted a bad example. Your solution is ok when it comes to going through all objects.

     

    But what I actually wanted was to know if it was possible to find the next element just from an object id without scanning the entire file or storing all the ids?

    Please use plain text.
    Moderator
    Alexander.Rivilis
    Posts: 1,168
    Registered: ‎04-09-2008

    Re: Next object in scan

    01-09-2013 05:06 AM in reply to: Fredrik.Larsen

    Fredrik.Larsen wrote:

    But what I actually wanted was to know if it was possible to find the next element just from an object id without scanning the entire file or storing all the ids?


    What do you mean by the next object?

    1. This could be the next ObjectId of entities within BlockTableRecord
    2. This can be ObjectId with Handle more by one than the Handle of current ObjectId for any object/entity in Database.

    In "pure" ObjectARX there is a function acdbEntNext - it can be used in .NET with help of P/Invoke but it return id only for entities (Entity) not for objects (DBObject)


    Пожалуйста не забывайте про Утвердить в качестве решения!Утвердить в качестве решения и Give Kudos!Баллы
    Please remember to Accept Solution!Accept as Solution and Give Kudos!Kudos

    Please use plain text.
    Active Contributor
    Posts: 34
    Registered: ‎11-28-2012

    Re: Next object in scan

    01-09-2013 05:14 AM in reply to: Alexander.Rivilis

    I think this could get too ugly too fast so I am stepping away from this approach. If someone deletes an object in the dwg you loose all control of what the next object is supposed to be and that is no good. Thanks anyways.

    Please use plain text.