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

Next object in scan

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
Fredrik.Larsen
472 Views, 4 Replies

Next object in scan

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

}

 

4 REPLIES 4
Message 2 of 5

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 ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)
Message 3 of 5

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?

Message 4 of 5


@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)

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

Message 5 of 5

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.

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