I've already finished in lisp so I hope nobody spends too much more time looking at this one.
For historical purposes. Here was the function.
......
//This one fails because the ename/ObjectId (of course) is not going to be the same with the same drawing in two different sessions.
//Handle is my only other option me thinks, but then I might have to make two different flavors, one for a handle and drawing, and the other for ObjectId in current drawing.
//I don't prefer to make handling Handles the default - I'd rather ObjectId's and avoid conversion/confusion.
//Would have to invent a way to detect if supplied var is ename or handle. Or just try catch i guess?? Use an overload once the var type is discovered. Also might need to cycle the drawings open in DocumentManager to avoid opening twice if it's already open in user session of autocad (non dbx).
As I'm sure you've already reconed, ObjectIds are database-specific and so are handles.
You can't identify an object in one database using an ObjectId or handle of an object in another database. In the case of a BlockTableRecord representing an xref, the only thing they have in common is the path of the xref'd drawing file.
However, you're jumping through a lot of hoops here, needlessly.
On the LISP side, you can open the database using ObjectDBX, get the vla-object of the AcadBlock representing the xref, and pass that to
(vlax-vla-object->ename), and then just pass the result to your LispFunction, which will get the ObjectId of the AcadBlock/BlockTableRecord.
The ObjectId class has a Database property, that returns the containing database, and that's what you would use to access anything else in the same database. (vlax-vla-object->ename) along with the Database property of the ObjectId is also the key to solving the more general problem of passing a database that was opened via ObjectDBX in LISP or another ActiveX consumer, to managed code. You just pass the entity name of any object in that database, and the ObjectId that comes out on the managed side, gives you the containing Database.