3D solid entity can be extruded by region object. So we can create a temporary region according to the boundary information of the existing polyline object.Here we explode the polyline to get the boundary curves, and create a temporary region with these boundary curves.
Please see the code snippet below as a reference.
void CreateExtrude()
{
Acad::ErrorStatus es;
ads_name polyName;
ads_point ptres;
//select the polyline
if( acedEntSel(L"Please select a polyline", polyName, ptres) != RTNORM)
{
acutPrintf(L"Failed to select a polyline");
return;
}
//get the boundary curves of the polyline
AcDbObjectId idPoly;
acdbGetObjectId(idPoly, polyName);
AcDbEntity *pEntity = NULL;
if(acdbOpenAcDbEntity(pEntity, idPoly, AcDb::kForRead) != Acad::eOk)
{
return;
}
AcDbPolyline *pPoly = AcDbPolyline::cast(pEntity);
if(pPoly == NULL)
{
pEntity->close();
return;
}
AcDbVoidPtrArray lines;
pPoly->explode(lines);
pPoly->close();
// Create a region from the set of lines.
AcDbVoidPtrArray regions;
es = AcDbRegion::createFromCurves(lines, regions);
if(Acad::eOk != es)
{
pPoly->close();
acutPrintf(L"\nFailed to create region\n");
return;
}
AcDbRegion *pRegion = AcDbRegion::cast((AcRxObject*)regions[0]);
// Extrude the region to create a solid.
AcDb3dSolid *pSolid = new AcDb3dSolid();
es = pSolid->extrude(pRegion, 10.0, 0.0);
for (int i = 0; i < lines.length(); i++)
{
delete (AcRxObject*)lines[i];
}
for (int ii = 0; ii < regions.length(); ii++)
{
delete (AcRxObject*)regions[ii];
}
AcDbObjectId savedExtrusionId = AcDbObjectId::kNull;
if(Acad::eOk == es)
{
AcDbDatabase *pDb = curDoc()->database();
AcDbObjectId modelId;
modelId = acdbSymUtil()->blockModelSpaceId(pDb);
AcDbBlockTableRecord *pBlockTableRecord;
acdbOpenAcDbObject((AcDbObject*&)pBlockTableRecord,
modelId, AcDb::kForWrite);
pBlockTableRecord->appendAcDbEntity(pSolid);
pBlockTableRecord->close();
pSolid->close();
}
else
{
delete pSolid;
}
}