Repository navigation
ObjectId GUID
#556
|
I need a GUID for an ObjectId. I tried using (filename, handle), but that won't work for unsaved databases. I was thinking of (filename, handle, tdcreate), which might not work for batch database creation either. Any ideas? |
Answered by
CEXT-Dan
Nov 10, 2026
Replies: 2 comments 1 reply
|
By the way, I see that creating a database via |
0 replies
|
There’s a AcDbDatabase::getFingerprintGuid function, but I missed it, I have added it and I’ll make a new release today. import traceback
from pyrx_imp import Ap, Db
from collections import defaultdict
# map ids to their databases
def allids():
ids : list[Db.ObjectId] = []
for db in Db.Core.activeDatabaseArray(): #this includes side databases
ids.extend(db.objectIds(Db.Entity.desc()))
return ids
def foo1():
id_map = defaultdict(list)
for id in allids():
id_map[id.database()].append(id)
return id_map
def foo2():
id_map = defaultdict(list)
for id in allids():
id_map[id.database().getFingerprintGuid()].append(id)
return id_map
def foo3():
id_map = defaultdict(list)
for id in allids():
id_map[id.database().runtimeId()].append(id)
return id_map
#this should print out at least 3 database sets
@Ap.Command()
def doit0():
try:
db1 = Db.Database()
db2 = Db.Database()
print(foo1())
except Exception:
traceback.print_exc()
@Ap.Command()
def doit1():
try:
db = Db.Database()
id = db.modelSpaceId()
print("{}-{}".format(id.handle(),id.database().getFingerprintGuid()))
except Exception:
traceback.print_exc()
@Ap.Command()
def doit2():
try:
db = Db.Database()
id = db.runtimeId()
testdb = Db.Database.dbPtrFromId(id)
print(id, id == testdb.runtimeId())
except Exception:
traceback.print_exc()
def getid():
db = Db.Database()
return db.runtimeId()
@Ap.Command()
def doit3():
try:
id = getid()
testdb = Db.Database.dbPtrFromId(id)
print(id, id == testdb.runtimeId())
# this should throw because the original database is dead:
except Exception:
traceback.print_exc()
|
1 reply
Answer selected by
gswifort
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
There’s a AcDbDatabase::getFingerprintGuid function, but I missed it, I have added it and I’ll make a new release today.
I’ve added some other tools that might be useful