Drawings SDK Developer Guide > Working with .dwg Files > Working with Databases > Working with Tagged Data > Getting and Setting Specific Data (color, binary, resbuf)
Getting and Setting Specific Data (color, binary, resbuf)

Tagged data can store additional specific information:

  • Color object — The group code 5011 defines a color object as an instance of the OdCmColor type.
  • Resbuf-object — The group code 5023 defines another resbuf-object as an instance of the OdResBuf type and is used for storing nested structures of resbuf-instances.
  • Binary chunk — Group codes 310 to 319 and 1004 define data as a binary chunk.

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.

Color Value

To get a color, use the getColor() method which does not have arguments and returns an instance of the OdCmColor type. For example:


OdCmColor color = pRb->getColor();
odPrintConsoleString(L"\nValue = %s", color.colorNameForDisplay().c_str());

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


OdCmColor color;
color.setRGB(25, 49, 16);
pRb->setRestype(OdResBuf::kRtColor);
pRb->setColor(color);

Note: The specific group code kRtColor (5011) defines the color object as data of the resbuf-object.

Binary Chunk Value

To get a binary chunk, use the getBinaryChunk() method which does not have arguments and returns an instance of the OdBinaryData type. For example:


OdBinaryData chunk = pRb->getBinaryChunk();

int i, size;
size = chunk.length();
  
odPrintConsoleString(L"\nChunk = ");
for(i=0 ; i < size ; i++)
  odPrintConsoleString(L"\n%x", chunk.at(i));

To set a binary chunk, use the setBinaryChunk() method which requires an instance of the OdBinaryData type as an argument and does not return a value. For example:


dBinaryData chunk;
chunk.clear();
chunk.append(0x45);
chunk.append(0xE2);
chunk.append(0x1D);
chunk.append(0x60);

pRb->setBinaryChunk(chunk);

Nested Group Codes

One resbuf-instance can be nested in another resbuf-instance as a data value. The specific group code kRtResBuf (5023) defines an instance of the OdResBuf type as data of the resbuf-object.

To get the nested resbuf-instance, use the getResBuf() method which does not have arguments and returns the typified smart pointer to the instance of the OdResBuf type. For example:


OdResBufPtr pNest = pRb->getResBuf();
odPrintConsoleString(L"\nNested ResBuf Type = %d", pNest->restype());

To set the resbuf-instance as a nested sub-structure, use the setResBuf() method which requires an instance of the OdResBuf type as an argument and does not return a value. For example:


OdResBufPtr pNest = OdResBuf::newRb();
pNest->setRestype(OdResBuf::kRtColor);
pNest->setColor(OdCmColor(OdCmEntityColor::kByACI));

pRb->setRestype(OdResBuf::kRtResBuf);
pRb->setResBuf(pNest);

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 – 2021. Open Design Alliance. All rights reserved.