Author Topic: c# detecting the newer line  (Read 2577 times)

0 Members and 1 Guest are viewing this topic.

kees987

  • Guest
c# detecting the newer line
« on: March 05, 2015, 06:06:44 AM »
When you have 2 lines, is there a way to find out what is the oldest drawn line, and what is the newer drawn line?
can i assume that the one with the higher ObjectId value is always the newer one ?

BillZndl

  • Bull Frog
  • Posts: 308
  • Retired
Re: c# detecting the newer line
« Reply #1 on: March 05, 2015, 07:06:17 AM »
When you have 2 lines, is there a way to find out what is the oldest drawn line, and what is the newer drawn line?
can i assume that the one with the higher ObjectId value is always the newer one ?

I use the Object.Id.Handle.Value when finding the last group created in the drawing.
That was long time ago so I don't remember all the details.
IIRC: It was something to do with the ObjectId changing each drawing session? IDK.
Goodbye friends! :)
Aug. I'll be leaving work for good.

kees987

  • Guest
Re: c# detecting the newer line
« Reply #2 on: March 05, 2015, 07:13:48 AM »
Yes it seems that when i close the drawing and reopen it, all the objectID's have changed.

For my situation i want to make sure that i get the new created lines within the same session. So thats why i need to know for sure it is not using any lower numbers.

looking at  Object.Id.Handle.Value, is it so that the higher value is always the newer created one, or does older removed entries get re-used ?
« Last Edit: March 05, 2015, 07:19:19 AM by kees987 »

huiz

  • Swamp Rat
  • Posts: 902
  • Certified Prof C3D
Re: c# detecting the newer line
« Reply #3 on: March 05, 2015, 07:22:31 AM »
Yes it seems that when i close the drawing and reopen it, all the objectID's have changed.

For my situation i want to make sure that i get the new created lines within the same session. So thats why i need to know for sure it is not using any lower numbers.

looking at  Object.Id.Handle.Value, is it so that the higher value is always the newer created one, or does older removed entries get re-used ?

You can test that by drawing some lines, remove the oldest, reopen the drawing and place a new line.

Handles will remain, ObjectIds don't.
The conclusion is justified that the initialization of the development of critical subsystem optimizes the probability of success to the development of the technical behavior over a given period.

kees987

  • Guest
Re: c# detecting the newer line
« Reply #4 on: March 05, 2015, 07:24:00 AM »
Yes it seems that when i close the drawing and reopen it, all the objectID's have changed.

For my situation i want to make sure that i get the new created lines within the same session. So thats why i need to know for sure it is not using any lower numbers.

looking at  Object.Id.Handle.Value, is it so that the higher value is always the newer created one, or does older removed entries get re-used ?

You can test that by drawing some lines, remove the oldest, reopen the drawing and place a new line.

Handles will remain, ObjectIds don't.

But how can you tell by just looking at a handle what is the latest created ones. Can i say with 100% certainty that a higher value handle is always newer, or will deleted entries (low numbers) get re-used?

Edit:
mm some tests already show me that just looking at the object ID, new lines can get a lower number than old lines. This doesnt help yet
« Last Edit: March 05, 2015, 07:29:19 AM by kees987 »

MexicanCustard

  • Swamp Rat
  • Posts: 705
Re: c# detecting the newer line
« Reply #5 on: March 05, 2015, 12:57:55 PM »
Are they in chronological order by their order in the database?  If you retrieve all objects in ModelSpace will you get the objects first added to last added?  I've never tried it but they should be there in the order they were added.
Revit 2019, AMEP 2019 64bit Win 10

huiz

  • Swamp Rat
  • Posts: 902
  • Certified Prof C3D
Re: c# detecting the newer line
« Reply #6 on: March 05, 2015, 01:42:42 PM »
..

But how can you tell by just looking at a handle what is the latest created ones. Can i say with 100% certainty that a higher value handle is always newer, or will deleted entries (low numbers) get re-used?

Edit:
mm some tests already show me that just looking at the object ID, new lines can get a lower number than old lines. This doesnt help yet

No test with ObjectId, but with Handles. ObjectIds are added when the drawing is opened and they disappear when the drawing gets closed. Handles are stored in the drawing database and will remain.
The conclusion is justified that the initialization of the development of critical subsystem optimizes the probability of success to the development of the technical behavior over a given period.

BillZndl

  • Bull Frog
  • Posts: 308
  • Retired
Re: c# detecting the newer line
« Reply #7 on: March 05, 2015, 03:07:45 PM »
Can i say with 100% certainty that a higher value handle is always newer,

I've used the objectId.Handle.Value on groups for years and it's never failed.
We use it all the time.

Goodbye friends! :)
Aug. I'll be leaving work for good.

Jeff H

  • Needs a day job
  • Posts: 6118
Re: c# detecting the newer line
« Reply #8 on: March 05, 2015, 04:23:07 PM »
If your needing a starting point for a session then Database.Handseed will give the handle that the database will use for next object.