Close

Relief for ODA Team in Ukraine

Learn more
ODA Drawings SDK
Getting and Setting Points and Vectors

Tagged data can store (two, three)-dimensional points and (two, three)-dimensional vectors as its data. Group codes 10 to 17, 110 to 112, 210, 1010 to 1013, 5002, and 5009 define data as a point or vector.

Points and vectors are instances of Ge classes. It is unimportant which Ge class the program will use for getting and setting the data. Methods of the resbuf-object automatically cast the stored value to an instance of the specified type, that is, if a resbuf-object stores a vector as a data type, then a point can be specified as a data value; and the reverse, if a resbuf-object stores a point as a data type then a vector can be specified as a data value. Methods of the resbuf-object automatically cast a three-dimensional pointor vector to a two-dimensional point or vector and disregards the Z-coordinate. In the examples, the pRbvariable stores a pointer to the resbuf-object.

2D Point Value

To get the two-dimensional point, use the getPoint2d() method that does not have arguments and returns an instance of the OdGePoint2d type. For example:


OdGePoint2d point2d = pRb->getPoint2d();
odPrintConsoleString(L"\nPoint (%g,%g)", point2d.x, point2d.y);

To set the two-dimensional point, use the setPoint2d() method that requires an instance of the OdGePoint2d type as an argument and does not return a value. For example:


OdGePoint2d point2d(2.3, 6.7);
pRb->setRestype(OdResBuf::kRtPoint2d);
pRb->setPoint2d(point2d);

3D Point Value

To get the three-dimensional point, use the getPoint3d() method that does not have arguments and returns an instance of the OdGePoint3d type. For example:


OdGePoint3d point3d = pRb->getPoint3d();
odPrintConsoleString(L"\nPoint (%g,%g,%g)", point3d.x, point3d.y, point3d.z);

To set the three-dimensional point, use the setPoint3d() method that requires an instance of the OdGePoint3d type as an argument and does not return a value. For example:


OdGePoint3d point3d(2.3, 6.7, 8.1);
pRb->setRestype(OdResBuf::kRtPoint3d);
pRb->setPoint3d(point3d);

2D Vector Value

To get the two-dimensional vector, use the getVector2d() method that does not have arguments and returns an instance of the OdGeVector2d type. For example:


OdGeVector2d vector2d = pRb->getVector2d();
odPrintConsoleString(L"\nVector (%g,%g)", vector2d.x, vector2d.y);

To set the two-dimensional vector, use the setVector2d() method that requires an instance of the OdGeVector2d type as an argument and does not return a value. For example:


OdGeVector2d vector2d(0.3, 0.7);
pRb->setRestype(OdResBuf::kRtVector2d);
pRb->setVector2d(vector2d);

3D Vector Value

To get the three-dimensional vector, use the getVector3d() method that does not have arguments and returns an instance of the OdGeVector3d type. For example:


OdGeVector3d vector3d = pRb->getVector3d();
odPrintConsoleString(L"\nVector (%g,%g,%g)", vector3d.x, vector3d.y, vector3d.z);

To set the three-dimensional vector, use the setVector3d() method that requires an instance of the OdGeVector3d type as an argument and does not return a value. For example:


OdGeVector3d vector3d(0.3, 0.7, 0.1);
pRb->setRestype(OdResBuf::kRtVector3d);
pRb->setVector3d(vector3d);

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.