The xrefBlockId() function will get the AcDbObjectId of the block table record, which refers to this database as an xref. When an xref is reloaded for any reason (for example, XREF Reload or XREF Path commands), the former database is kept in memory for Undo. This means that more than one database may point to the same xref block table record. However only one will be the currently active xref database for that record. The database pointer returned by the AcDbBlockTableRecord::xrefDatabase() function on the found record will be the active database for that xref.