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

store vlaues with Xrecords

27 REPLIES 27
SOLVED
Reply
Message 1 of 28
youssefGC
1481 Views, 27 Replies

store vlaues with Xrecords

Hi forums,

 

Is there a method to store a pair of data values (dictionary < key, list<objectid>>) in once key in the Xrecords of an entity?

 

Thank you.

 

27 REPLIES 27
Message 21 of 28

Indeed, I tested the solution and it works very well for me. Thanks again. I will mark it as the solution.

 

Message 22 of 28
timgrote
in reply to: ActivistInvestor

Working with entity parent/child relationships, I'm storing the handles (string) as xdata on the entity. My understanding was that ObjectIds are not constant between editing sessions, handles are. Am I wrong in this understanding, is it better(more direct) to store an ObjectId?

Message 23 of 28
norman.yuan
in reply to: youssefGC

If you save the data in DBDictionary as Xrecord, you can save ObjectId as TypedValue((int)DxfCode.SoftPointerId, [ObjectId]). In this case, the paired value is actually (330, [Handle]), but it saves your code from having to convert ObjectId<=>Handle.

 

Norman Yuan

Drive CAD With Code

EESignature

Message 24 of 28
ActivistInvestor
in reply to: timgrote


@timgrote wrote:

Working with entity parent/child relationships, I'm storing the handles (string) as xdata on the entity. My understanding was that ObjectIds are not constant between editing sessions, handles are. Am I wrong in this understanding, is it better(more direct) to store an ObjectId?


Use handles when you need to reference objects in a DWG file externally (e.g., from a SQL table, or some other data that is external to a DWG file). That usually also requires a reference to the DWG file as well as the handle of something within it.

 

Use ObjectIds when you need to reference other objects in the same DWG file, since the references are maintained across editing sessions (ObjectId-based references are converted to/from handles when the file is saved/opened).

 

The more important thing is that handles stored in Xdata may not always be translated by AutoCAD during operations like COPY, etc. For that, the preferred solution is to store handles in an Xrecord that has its XlateReferences property set to true.

Message 25 of 28

Many years ago HANDLE was added to allow linking to databases, at the time dBase, and there was also the option to "turn off" and "turn on" them.

If we were today, they would probably define them as GUID.
After that they added XDATA which allows you to save a key to link to a database in a more "correct" way, and from that CAO evolved.
It is currently not recommended to use HANDLE as a link from a database to entities in a drawing.
(There is a bug when the value of HANDLE, Overflow, the file is destroyed)

Message 26 of 28

Handles are hex representations of a 64 bit number.  It's not that easy to overflow them. 

 

 

Message 27 of 28

The bug is that there is no check when HANDLE approaches the edge.
You can edit a DXF file and change the value of $HANDSEED there to a value close to the edge, for example FFFFFFFFFFFFFE3
Then open the file and perform several actions that create new entities.

Message 28 of 28

Like I said, overflowing handles during regular use (verses editing $HANDSEED) is extremely difficult to do.

 

And, handles can be reset by doing a full WBLOCK of the file (but requires reconciliation with external references).

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Forma Design Contest


AutoCAD Beta