Drawings SDK Developer Guide > Working with .dwg Files > Working with Entities > Working with Specific Entitites > Working with Shapes > Specific Shape Properties
Specific Shape Properties

The shape object uses the position, normal, thickness, height factor, width factor, oblique angle and rotation angle properties to define the geometry to be drawn. In the following examples, the pShape variable stores a pointer to the shape object.

Position

The property defines the position in which the shape entity is inserted in three-dimensional coordinates. The position coincides with the origin from which the shape geometry is drawn. The position has the coordinates (0,0,0) by default.

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


OdGePoint3d position = pShape->position();
odPrintConsoleString(L"\nPosition = (%g,%g,%g)", position.x, position.y, position.z);

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


OdGePoint3d point(3.2, 1.5, 0.8);
pShape->setPosition(point);

Normal

The property defines the normal to the plane in which the shape is placed. The normal defines the orientation of the shape in world space. The normal has the coordinates (0,0,1) by default.

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


OdGeVector3d normal = pShape->normal();
odPrintConsoleString(L"\nNormal = (%g,%g,%g)", normal.x, normal.y, normal.z);

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


OdGeVector3d vector(0.606, 0.101, 0.303);
pShape->setNormal(vector);

Note: The setNormal() method automatically converts the specified coordinates to the unit vector. For example:


pShape->setNormal( OdGeVector3d(2.5, 1.2, 3.4) );
OdGeVector3d result = pShape->normal();
odPrintConsoleString(L"\n(%g, %g, %g)", result.x, result.y, result.z);    // (0.569803, 0.273505, 0.774932)

Plane

A shape is a planar entity. The planarity is kPlanar, and the plane is oriented to (0·X + 0·Y + 1·Z + 0) by default.

To get the shape plane, use the getPlane() method which requires a reference to a variable of the OdGePlane type in which the plane instance must be saved as the first argument, a reference to a variable of the OdDb::Planarity type in which the plane type must be saved as the second argument, and returns the plane properties through arguments and the resulting code. For example:


OdGePlane plane;
double a, b, c, d;
OdDb::Planarity planarity;

OdResult eRes = pShape->getPlane(plane, planarity);

if(eRes == eOk && planarity != OdDb::kNonPlanar)
{
  plane.getCoefficients(a, b, c, d);
  odPrintConsoleString(L"Shape plane is (%g * X + %g * Y + %g * Z + %g)", a, b, c, d);
}

Note: The isPlanar() method returns True for the shape entity.

Thickness

The property defines the thickness of the shape figure as a Double value in drawing units. A positive value defines the thickness to be drawn along the normal direction. A negative value defines the thickness to be drawn in the opposite direction from the normal. A zero value defines a shape without thickness. The thickness is zero by default.

To get the thickness, use the thickness() method which does not have arguments and returns the thickness as a Double value. For example:


odPrintConsoleString(L"\nThickness = %g", pShape->thickness());

To set the thickness, use the setThickness() method which requires a Double value as an argument and does not return a value. For example:


pShape->setThickness(1.5);

Rotation Angle

The property defines the rotation angle in radians on which the shape is rotated relative to the OCS X-axis around the shape position in the range ±2PI radians. A positive angle is measured and rotates the shape counterclockwise (to the left). A negative angle is measured and rotates the shape clockwise (to the right). A zero angle indicates that the shape is not rotated and is drawn in the direction of the OCS X-axis. The shape entity stores the rotation angle value together with the sign and does not convert it to an equivalent angle. The rotation angle is zero by default.

To get the rotation angle, use the rotation() method which does not have arguments and returns the angle as a Double value. For example:


odPrintConsoleString(L"\nRotation angle = %g", pShape->rotation());

To set the rotation angle, use the setRotation() method which requires a Double value as an argument and does not return a value. For example:


pShape->setRotation(0.303);

Note: The setRotation() method does not convert to an equivalent angle and sets the initially specified value.

Oblique Angle

The property defines the oblique angle in radians on which the shape is sloped relative to the OCS Y-axis in the range ±2PI radians. The effective angle range is ±1.4827 radians (±85 degrees). A positive angle is measured and slopes the shape clockwise (to the right). A negative angle is measured and slopes the shape counterclockwise (to the left). A zero angle indicates that the shape is not sloped. The shape entity stores the oblique angle value together with the sign and does not convert it to an equivalent angle. The oblique angle is zero by default.

To get the oblique angle, use the oblique() method which does not have arguments and returns the angle as a Double value. For example:


odPrintConsoleString(L"\nOblique angle = %g", pShape->oblique());

To set the oblique angle, use the setOblique() method which requires a Double value as an argument and does not return a value. For example:


pShape->setOblique(0.202);

Note: The setOblique() method does not convert to an equivalent angle and sets the initially specified value.

Height Scale Factor

The property defines the height scale factor which scales the shape size. This factor influences the width and height together and is used for proportional scaling of the shape boundary. If the factor value is less than 1.0, the shape size decreases. If the factor value is greater than 1.0, the shape size increases. If the factor value is 1.0, the shape has its original size. The shape entity stores the specified factor value without conversion, but the effective factor value must be a positive non-zero double value. The height scale factor is 1.0 by default.

To get the height scale factor, use the size() method which does not have arguments and returns the factor as a Double value. For example:


odPrintConsoleString(L"\nHeight scale factor = %g", pShape->size());

To set the height scale factor, use the setSize() method which requires a Double value as an argument and does not return a value. For example:


pShape->setSize(0.8);

Width Scale Factor

The property defines the width scale factor which scales the shape width when the height is constant. This factor influences only the width. If the factor value is less than 1.0, the shape is condensed. If the factor value is greater than 1.0, the shape is expanded. If the factor value is 1.0, the shape has its original size. The shape entity stores the specified factor value without conversion, but the effective factor value must be a positive non-zero double value. The width scale factor is 1.0 by default.

To get the width scale factor, use the widthFactor() method which does not have arguments and returns the factor as a Double value. For example:


odPrintConsoleString(L"\nWidth scale factor = %g", pShape->widthFactor());

To set the width scale factor, use the setWidthFactor() method which requires a Double value as an argument and does not return a value. For example:


pShape->setWidthFactor(1.5);

See Also

Working with Shapes

Appearance of Shape Properties

Example of Working with the Shape Object

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