|
Get the geometry from a dimension entity
[code]// Iterate every entity stored in the
// block definition of the dimension.
for (; !pIter->done(); pIter->step())
{
AcDbEntity *pEnt; pIter->getEntity(pEnt, AcDb::kForRead);
if (pEnt->isKindOf(AcDbLine::desc()))
{
AcDbLine *pLine = (AcDbLine*) pEnt;
// Get the start and end point.
AcGePoint3d ptStart,
ptEnd; pLine->getStartPoint(ptStart);
pLine->getEndPoint(ptEnd);
// // Transform the start and end point.
// // Get the transformation matrix.
AcGeMatrix3d mat;
// Get the axis of the dimension entity.
AcGeVector3d zAxis(pDim->normal());
AcGeVector3d xAxis(zAxis.perpVector());
AcGeVector3d yAxis(zAxis.crossProduct(xAxis));
// Build the transformation matrix.
mat.setToAlignCoordSys(AcGePoint3d::kOrigin,
AcGeVector3d(1.0, 0.0, 0.0),
AcGeVector3d(0.0, 1.0, 0.0),
AcGeVector3d(0.0, 0.0, 1.0),
AcGePoint3d::kOrigin,
xAxis, yAxis, zAxis);
// z axis
// To test this matrix create a new line
// using the start and endpoint of the line
// from the block definition, and transform
// the line using the calculated transformation matrix.
AcDbLine *pNewLine = new AcDbLine(ptStart, ptEnd);
pNewLine->transformBy(mat);
AcGePoint3d nptStart, nptEnd;
pNewLine->getStartPoint(nptStart);
pNewLine->getEndPoint(nptEnd);
pNewLine->setColorIndex(4);
// Append the new line to the model space and close it.
// The new line should be at the location
// of the dimension entity.
AppendToModelSpaceAndClose(pNewLine);
}
pEnt->close();
}[/code] |
|