ObjectARX, AutoCAD. Среда программирования библиотеки C++




Пример вложенных транзакций - часть 6


{

case RTNORM:

if (nSides < 3)

acutPrintf("\nNeed at least 3 sides.");

break;

default:

return Acad::eInvalidInput;

}

}

ads_point center, startPt, normal;

if (acedGetPoint(NULL, "\nLocate center of polygon: ", center) != RTNORM)

{

return Acad::eInvalidInput;

}

startPt[0] = center[0];

startPt[1] = center[1];

startPt[2] = center[2];

while (asPnt3d(startPt) == asPnt3d(center)) {

switch (acedGetPoint(center, "\nLocate start point of polygon: ", startPt)) {

case RTNORM:

if (asPnt3d(center) == asPnt3d(startPt))

acutPrintf("\nPick a point different"

" from the center.");

break;

default:

return Acad::eInvalidInput;

}

}

// Set the normal to the plane of the polygon to be

// the same as the Z direction of the current UCS,

// (0, 0, 1) since we also got the center and

// start point in the current UCS. (acedGetPoint()

// returns in the current UCS.)

normal[X] = 0.0;

normal[Y] = 0.0;

normal[Z] = 1.0;

acdbUcs2Wcs(normal, normal, Adesk::kTrue);

acdbUcs2Ecs(center, center, normal, Adesk::kFalse);

acdbUcs2Ecs(startPt, startPt, normal, Adesk::kFalse);

double elev = center[2];

AcGePoint2d cen = asPnt2d(center),

start = asPnt2d(startPt);

AcGeVector3d norm = asVec3d(normal);

AsdkPoly *pPoly = new AsdkPoly;

if (pPoly==NULL)

return Acad::eOutOfMemory;

Acad::ErrorStatus es;

if ((es=pPoly->set(cen, start, nSides, norm, "transactPoly",elev))!=Acad::eOk)

return es;

pPoly->setDatabaseDefaults( acdbHostApplicationServices()->workingDatabase());

postToDb(pPoly);

return Acad::eOk;

}

// Extrudes the poly to a given height.

//

static Acad::ErrorStatus

extrudePoly(AsdkPoly* pPoly, double height, AcDbObjectId& savedExtrusionId)

{

Acad::ErrorStatus es = Acad::eOk;

// Explode to a set of lines.

//

AcDbVoidPtrArray lines;

pPoly->explode(lines);

// Create a region from the set of lines.

//

AcDbVoidPtrArray regions;

AcDbRegion::createFromCurves(lines, regions);




Содержание  Назад  Вперед