I hear ya. Bad suggestion on 1005... And wouldn't want to start telling you what direction to go in;
The ObjectID *should* be convertable back to a handle or object.
Provided you store an ename/objectID in the first place... and not a handle (as your post clearly indicates). I can only speculate why it worked before (that is, storing a handle)... Perhaps a translation was occuring. I have both a 32 and 64, and I can't store a handle in those code ranges. If I try storing a handle as a dxf 330, I get.
; error: bad DXF group: (331 . "27E")
...fiddle with the high byte/low byte theory...
Saw
this and
this, but couldn't figure it out. Not big on math and bit shifting.
This needs to be persistent between sessions.
Object ID's in the 330 range are. They change, but autocad sorts out all the references and all 330 ranges, etc. at load time. I know that's a contradiction in terms (again), none the less, the dynamic nature of the id's combined with 330 series can derive the persistant handles you seek.
The 330 group is used for soft-pointer handle storage, returning ObjectIDs rather than the original string value (handle).
I know some docs say handle, but this is a terminology clash. It doesn't store handles and return objectids. No Way Jose. Stores objectids/ename -> returns objectids/ename. entget the returned ename, and you'll get the correct object every time. If you want the handle, then get that after the entget. (cdr (assoc 5 (entget (car (_refobjID)))))
I get the results you describe you want with current dwg,
xref, and block insert or block insert explode, using the following quick xrecord write (see next code).
NOTE: If storing in namedobjectdict, it (custom dict) doesn't make it into the dwg it is being inserted into; So I stored on a line object extended dict.As far as xref. Using nentsel, the handle of the objects in the xref are the same as the source drawing. They don't get their own handles when being xref'd. However the 330 objectid does corrently resolve to the corrent entity in the reffing dwg, and of course acts as an inserted block described above, when xref-bind-insert, etc.
I go about creating the xrecord and dict a little unconventionaly, so sorry for the code vomit. But this shows me the 330 range works on both 32 & 64 bit IF using
objectids/enames.
NOTE: I tested by using a circle and a line.
(setq prmpref "Select object you want to reference"
prmpstor "Select object you want to store the information on"
prmpget "Select object you want to retrieve information from")
;make
;using 331 because it's more simple to find
(setq EanXrec (entmakex (list '(0 . "XRECORD")
'(100 . "AcDbXrecord")
(cons 331 (car (entsel prmpref))))))
(setq line (vlax-ename->vla-object (car (entsel prmpstor))))
(setq extdic (vla-getextensiondictionary line))
(setq Eextdic(vlax-vla-object->ename extdic))
(dictadd Eextdic "MYDIC" EanXrec)
;read in current drawing
(setq extdic (vla-getextensiondictionary (vlax-ename->vla-object (car (entsel prmpget)))))
(setq Eextdic (vlax-vla-object->ename extdic))
(setq Eanxrec (cdr (assoc -1 (dictsearch Eextdic "MYDIC"))))
(setq recobj (entget Eanxrec))
(setq Eref (cdr (assoc 331 recobj)))
(setq refobj (entget eref))
;read in xrefing drawing or bind-insert or inserted block.
(setq extdic (vla-getextensiondictionary (vlax-ename->vla-object (car (nentsel prmpget)))))
(setq Eextdic (vlax-vla-object->ename extdic))
(setq Eanxrec (cdr (assoc -1 (dictsearch Eextdic "MYDIC"))))
(setq recobj (entget Eanxrec))
(setq Eref (cdr (assoc 331 recobj)))
(setq refobj (entget eref))
;handle test
;run on reference object before inserting or on exploded block objects on new drawing
(setq handle (cdr (assoc 5 (entget (car (entsel))))))
;run on inserted block object (unexploded)
(setq handle (cdr (assoc 5 (entget (car (nentsel))))))
Attached are the files I used to experiment. Drawing2.dwg contains a crapload of rectangls, to ensure no chance of coincidence in the handles being the same with a fresh acad.dwt.