Author Topic: Object persistant data past save?  (Read 1051 times)

0 Members and 1 Guest are viewing this topic.

Tuoni

  • Gator
  • Posts: 3032
  • I do stuff, and things!
Object persistant data past save?
« on: February 16, 2007, 04:59:30 AM »
I am writing a routine which carries out a series of calculations on an AutoCAD drawing, getting areas of polylines etc etc, but I have stumbled across a... "brainteaser" (certainly for my little VBA'd-to-death brain).

I allow the user to make a selectionset of objects they do not wish to be included in the calculation, and until now I have been storing their ObjectID, Layer name and Area in list boxes.  They also have the ability to delete an object from the "Excluded" list.  This is fine within the same session, HOWEVER, something I never checked is whether this data is persistant past a save.  Which it isn't.  When you close and re-open a drawing, the ObjectID of any given object is different to the last time you had it open.

I have toyed with the idea of creating "on-the-fly" excluded layers (with the extension "-excluded") for each object they select and then moving the object to that layer.  This idea is fine for excluding an object, but what happens if there is more than one object on the same layer which is excluded (or for blocks, two with the same name)?  How will my script know which to include in the calculations again?

I could, of course, store some additional data on the object for example its area, but this relies on the fact that the user will not change the area of the polyline past it being excluded from the calculations, and also will not work for blocks.

Anyone any suggestions?

hendie

  • Guest
Re: Object persistant data past save?
« Reply #1 on: February 16, 2007, 05:40:09 AM »
I would go for Xdata.
You could add an "exclude me" identifier to objects with Xdata then just filter those out for your calculations.

Tuoni

  • Gator
  • Posts: 3032
  • I do stuff, and things!
Re: Object persistant data past save?
« Reply #2 on: February 16, 2007, 05:42:16 AM »
Thanks, that thought hadn't even crossed my mind :ugly:.  I will get to it now :)

Chuck Gabriel

  • Guest
Re: Object persistant data past save?
« Reply #3 on: February 16, 2007, 07:38:39 AM »
I'm not sure I completely understand your problem, but it sounds like at least part of it is due to the fact that ObjectId's are not persistent from one AutoCAD session to another.  If so, you might want to look at the information on handles in the documentation.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16723
  • Superior Stupidity at its best
Re: Object persistant data past save?
« Reply #4 on: February 16, 2007, 08:50:51 AM »
I'm not sure I completely understand your problem, but it sounds like at least part of it is due to the fact that ObjectId's are not persistent from one AutoCAD session to another.  If so, you might want to look at the information on handles in the documentation.

I was going to say the same thing ... the handles are persistent until/unless you wblock the drawing (which I do frequently)
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Glenn R

  • Water Moccasin
  • Posts: 1932
  • What idiot child of married cousins wrote this?!
Re: Object persistant data past save?
« Reply #5 on: February 16, 2007, 05:01:07 PM »
Handles in a Dictionary for persistent object exclusion...'nuff said.

Great minds think alike eh Chuck? :)

Cheers,
Glenn.
Me

Glenn R

  • Water Moccasin
  • Posts: 1932
  • What idiot child of married cousins wrote this?!
Re: Object persistant data past save?
« Reply #6 on: February 16, 2007, 05:01:43 PM »
BTW, ObjectIds are calculated off the handle amongst other things...
Me

Chuck Gabriel

  • Guest
Re: Object persistant data past save?
« Reply #7 on: February 19, 2007, 10:32:25 AM »
Handles in a Dictionary for persistent object exclusion...'nuff said.

Great minds think alike eh Chuck? :)

Cheers,
Glenn.

The doctors say that Glenn and I aren't really two distinct people.  They think Glenn is just the part of me that surfaces when I need to be strong, but we know better.  Don't we Glenn?  Oh yes, we know...  :D

Glenn R

  • Water Moccasin
  • Posts: 1932
  • What idiot child of married cousins wrote this?!
Re: Object persistant data past save?
« Reply #8 on: February 19, 2007, 06:10:32 PM »
Know...? Know what...!? Who said that!?!  :evil:
Me

Tuoni

  • Gator
  • Posts: 3032
  • I do stuff, and things!
Re: Object persistant data past save?
« Reply #9 on: February 20, 2007, 06:44:44 AM »
Sorry for the delay in getting back... I went with the handles idea over faffing with XData - appears to work fine :)

Thanks guys.