用 getGeomExtents 得到实体的外围框后再添加一个轻多段线就可以吧...
void test() { ads_name en; ads_point pt; if(acedEntSel("\nSpecify a object:",en,pt)!=RTNORM) return; AcDbObjectId eId; acdbGetObjectId(eId,en); AcDbEntity *pEnt; acdbOpenAcDbEntity(pEnt,eId,AcDb::kForRead); AcDbExtents exts; if(pEnt->getGeomExtents(exts)!=Acad::eOk) { acutPrintf("\n**Error on get the extents point..."); pEnt->close(); return; } acutPrintf("\nThe maxPoint=%0.4f,%0.4f",exts.maxPoint()[X],exts.maxPoint()[Y]); acutPrintf("\nThe minPoint=%0.4f,%0.4f",exts.minPoint()[X],exts.minPoint()[Y]); pEnt->close(); // will be add a polyline to the ModelSpace // the vertex point will be add to the ptArray AcGePoint3dArray ptArray; ptArray.append(exts.minPoint()); AcGePoint3d ptTemp; ptTemp[X]=exts.maxPoint()[X]; ptTemp[Y]=exts.minPoint()[Y]; ptTemp[Z]=exts.minPoint()[Z]; ptArray.append(ptTemp); ptArray.append(exts.maxPoint()); ptTemp[X]=exts.minPoint()[X]; ptTemp[Y]=exts.maxPoint()[Y]; ptTemp[Z]=exts.minPoint()[Z]; ptArray.append(ptTemp);
AcDb2dPolyline *pNewLine=new AcDb2dPolyline(AcDb::k2dSimplePoly,ptArray,0.0,Adesk::kTrue); pNewLine->setColorIndex(1);
AcDbBlockTable *pBlockTable; acdbHostApplicationServices()->workingDatabase()->getSymbolTable(pBlockTable,AcDb::kForRead); AcDbBlockTableRecord *pMS; pBlockTable->getAt(ACDB_MODEL_SPACE,pMS,AcDb::kForWrite); pBlockTable->close(); pMS->appendAcDbEntity(eId,pNewLine); pNewLine->close(); pMS->close(); } |