.NET

Reply
Active Contributor
Fredrik.Larsen
Posts: 46
Registered: ‎11-28-2012
Message 1 of 5 (178 Views)
Accepted Solution

Next object in scan

178 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

}

 


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)

*Expert Elite*
Alfred.NESWADBA
Posts: 9,217
Registered: ‎06-29-2007
Message 2 of 5 (173 Views)

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
-------------------------------------------------------------------------
Active Contributor
Fredrik.Larsen
Posts: 46
Registered: ‎11-28-2012
Message 3 of 5 (154 Views)

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?

Moderator
Alexander.Rivilis
Posts: 1,433
Registered: ‎04-09-2008
Message 4 of 5 (149 Views)

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

Active Contributor
Fredrik.Larsen
Posts: 46
Registered: ‎11-28-2012
Message 5 of 5 (145 Views)

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.

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.