Close

Relief for ODA Team in Ukraine

Learn more
ODA Drawings SDK
Getting and Setting Objects

Tagged data can store an object or reference to an object.

  • Group codes 5, 105, 320 to 329, 390 to 399, and 1005 define a handle object as an instance of the OdDbHandle type.
  • Group codes 5006, (–1) define an object ID as an instance of the OdDbObjectId type.
  • Group codes 330 to 339 define a soft pointer ID to an existing object as an instance of the OdDbSoftPointerID type.
  • Group codes 340 to 349 define a hard pointer ID to an existing object as an instance of the OdDbHardPointerID type.
  • Group codes 350 to 359 define a soft ownership ID to an existing object as an instance of the OdDbSoftOwnershipID type.
  • Group codes 360 to 369 define a hard ownership ID to an existing object as an instance of the OdDbHardOwnershipID type.

Group codes store the soft and hard pointer and ownership IDs as a handle. Only group codes 5006 and (–1) store IDs as an object ID.

In the following examples, the pRb variable stores a pointer to the resbuf-object, and the pDb variable stores a pointer to the database object.

Handle Value

To get the handle, use the getHandle() method which does not have arguments and returns an instance of the OdDbHandle type. For example:


OdDbHandle handle = pRb->getHandle();
odPrintConsoleString(L"\nH = %s", handle.ascii().c_str());

To set the handle, use the setHandle() method which requires an instance of the OdDbHandle type as an argument and does not return a value. For example:


handle = 0x4E5D;
pRb->setRestype(OdResBuf::kRtHandle);
pRb->setHandle(handle);

Object ID Value

To set the object ID, use the setObjectId() method which requires an instance of the OdDbObjectId type as an argument and does not return a value. To store the object ID as a data value, the group code must be set to kRtEntName (5006) or kDxfEnd (–1). For example:


id = pDb->getLayerZeroId();
pRb->setRestype(OdResBuf::kRtEntName);
pRb->setObjectId(id);

If the group code is set to kRtEntName or kDxfEnd, the setObjectId() method casts and saves the passed instance as an object ID, otherwise, if the group code is another, the method converts the passed object ID to the handle associated with the ID using the getHandle() method of the OdDbObjectId object passed as an argument. As a result, the resbuf-instance stores an instance of the OdDbHandle type and a program must use the getHandle() method for getting a data value. Only if the group code is set to kRtEntName or kDxfEnd, the resbuf-instance stores an instance of the OdDbObjectId type and a program must use the getEntName() method for getting a data value. For example:


id = pDb->getTextStyleStandardId();
pRb->setRestype(OdResBuf::kRtObjectId);
pRb->setObjectId(id);

// Then get handle instead of ID
OdDbHandle handle = pRb->getHandle();
odPrintConsoleString(L"\nH = %s", handle.ascii().c_str());

To get the object ID for kRtEntName and kDxfEnd codes, use the getEntName() method which does not have arguments and returns an instance of the OdDbObjectId type. For example:


OdDbObjectId id = pRb->getEntName();
odPrintConsoleString(L"\nID = %s", id.getHandle().ascii().c_str());

To get the object ID for soft or hard pointers or ownerships, use the getObjectId() method which requires a pointer to the database as an argument and returns an instance of the OdDbObjectId type. This method uses the getOdDbObjectId() method of the passed database object to get the object ID associated with the handle stored in the resbuf-instance. For example:


OdDbObjectId id = pRb->getObjectId(pDb);
odPrintConsoleString(L"\nID = %s", id.getHandle().ascii().c_str());

Note: When the data type is not set to kRtEntName or kDxfEnd, the getEntName() method generates the exception "68 - Invalid ResBuf". The getObjectId() method returns the object ID for all ID codes.

Note: The passed data value must correspond to the specified data type, otherwise the exception "68 - Invalid ResBuf" occurs.

See Also

Working with Tagged Data

Determining the Data Type by Group Code

Example of Entering and Displaying Tagged Data

Copyright © 2002 – 2022. Open Design Alliance. All rights reserved.