.NET

Reply
Active Contributor
Posts: 45
Registered: ‎11-28-2012
Message 1 of 5 (152 Views)
Accepted Solution

Next object in scan

152 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

}

 

*Expert Elite*
Alfred.NESWADBA
Posts: 8,588
Registered: ‎06-29-2007
Message 2 of 5 (147 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
Posts: 45
Registered: ‎11-28-2012
Message 3 of 5 (128 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,346
Registered: ‎04-09-2008
Message 4 of 5 (123 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
Posts: 45
Registered: ‎11-28-2012
Message 5 of 5 (119 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.

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you interested in helping shape the Autodesk Community?
We’re looking at a few different ways to improve the “All Forums” landing page and need your feedback! If interested, please take a few minutes to fill out the following Usability Study. Thank you for your time!

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community