Tagged data can store a string value, grouped into the following categories:
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.
To get any string value, use the getString() method which does not have arguments and returns an instance of the OdString type. For example:
OdString sValue = pRb->getString();
odPrintConsoleString(L"\nValue = %s", sValue.c_str());
To set the string value, use the setString() method which requires an instance of the OdString type as an argument and does not return a value.
To set an arbitrary string, pass the OdString instance and ascii- or wide-characters string to the setString() method. For example:
sValue = OD_T("Some Text");
pRb->setRestype(1000);
pRb->setString(sValue);
pRb->setRestype(300);
pRb->setString(L"wide-string");
pRb->setRestype(470);
pRb->setString("ascii-string");
To set a control string, pass the left brace for opening a block or right brace for closing a block to the setString() method. Only the 102 or 1002 codes are controlled and must be used in pairs: (102,"{") — (102,"}") for DXF technology or (1002,"{") — (1002,"}") for XData technology. For example:
// Open a block
pRb->setRestype(102);
pRb->setString("{");
// Close a block
pRb->setRestype(102);
pRb->setString("}");
To set a name, set the data type corresponding to the specified object and pass the name of an existing object to the setString() method as a data value. For example:
// Set the layer name
OdDbLayerTableRecordPtr pLayer = pDb->getLayerZeroId().safeOpenObject();
pRb->setRestype(1003);
pRb->setString(pLayer->getName());
// Set the text style name
OdDbTextStyleTableRecordPtr pTextStyle = pDb->getTextStyleStandardId().safeOpenObject();
pRb->setRestype(7);
pRb->setString(pTextStyle->getName());
Note: The passed data value must correspond to the specified data type, otherwise the exception "68 - Invalid ResBuf" occurs. When a string is a name, the object must exist in the database.
Determining the Data Type by Group Code
Example of Entering and Displaying Tagged Data
Copyright © 2002 – 2021. Open Design Alliance. All rights reserved.
|