The database object and its objects have specific methods that return an ID of the required object.
In the examples below, the pHost variable stores a pointer to the host application object and the pDb
variable stores a pointer to the database object.
OdDbDabasePtr pDb = pHost->createDatabase(); // Db = 3c9b8
To get an ID of an existing object with a handle, use the getOdDbObjectId() method of the database
object; it requires a handle of the object and returns the ID associated with this object. For example:
OdDbHandle handle = 0x1F;
OdDbObjectId id = pDb->getOdDbObjectId(handle);
odPrintConsoleString(L"\nHandle = %llx, Db = %lx, Obj = %lx", id.getHandle(), id.database(), id.openObject());
// Handle = 1f, Db = 3c9b8, Obj = 6a5b2
To add an object in a database and associate an ID with it, use the addOdDbObject() method of the database
object; it requires a pointer to the object and returns the ID associated with this object as a result of the
addition. The object gets the next free handle. For example:
To get an ID of an existing object that has a pointer, use the objectId() method of the object; it does
not have arguments and returns the ID associated with this object. For example:
To get an ID of the owner object, use the ownerId() method of the object; it does not have arguments and returns
the ID associated with its owner. For example:
To get an ID of the predefined object of a database, use the specific method of the database object using the ID associated with the predefined object. For example, to get the standard text style of a drawing, use
the following specific method:
To get the handle of an existing object that has a pointer, use the handle() method of the object; it does not have arguments and returns the handle associated with this object. For example: