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.
Solved! Go to Solution.
Solved by ActivistInvestor. Go to Solution.
Indeed, I tested the solution and it works very well for me. Thanks again. I will mark it as the solution.
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?
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.
@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.
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)
Handles are hex representations of a 64 bit number. It's not that easy to overflow them.
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.
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.