AcDbObjectId PostToMS(AcDbEntity *pEnt) { AcDbBlockTable *pBlkTbl; acdbHostApplicationServices()->workingDatabase()->getBlockTable(pBlkTbl, AcDb::kForRead); AcDbBlockTableRecord *pMS; pBlkTbl->getAt(ACDB_MODEL_SPACE,pMS,AcDb::kForWrite); pBlkTbl->close(); AcDbObjectId EntID; pMS->appendAcDbEntity(EntID,pEnt); pMS->close(); return EntID; }
static void ROYMyTest_test1(void) { // Add your code for command ROYMyTest._test1 here ads_point pt; ads_name ename; AcDbObjectId EntID; AcDbEntity *pEnt=NULL; if (acedEntSel(_T("\nSelect a line or arc:"),ename,pt)!=RTNORM || acdbGetObjectId(EntID,ename)!=Acad::eOk || acdbOpenAcDbEntity(pEnt,EntID,AcDb::kForRead)!=Acad::eOk) return; if (!(pEnt->isKindOf(AcDbLine::desc()) || pEnt->isKindOf(AcDbArc::desc()))) { pEnt->close(); return; } AcDbLine *pLine; AcDbArc *pArc; AcGePoint3d ptStart,ptEnd; double dBugle,startAngle,endAngle,dAngle; if (pEnt->isKindOf(AcDbLine::desc())) { pLine=AcDbLine::cast(pEnt); if (pLine!=NULL) { ptStart=pLine->startPoint(); ptEnd=pLine->endPoint(); dBugle=0; } } else { pArc=AcDbArc::cast(pEnt); if (pArc!=NULL) { pArc->getStartPoint(ptStart); pArc->getEndPoint(ptEnd); startAngle=pArc->startAngle(); endAngle=pArc->endAngle(); if (endAngle<startAngle) endAngle+=8*atan(1.0); dAngle=endAngle-startAngle; dBugle=tan(dAngle/4); } } if (pEnt->upgradeOpen()!=Acad::eOk) { pEnt->close(); return; } pEnt->erase(); pEnt->close();
AcDbPolyline *pPLine; pPLine=new AcDbPolyline(2); pPLine->addVertexAt(0,asPnt2d(asDblArray(ptStart)),dBugle); pPLine->addVertexAt(1,asPnt2d(asDblArray(ptEnd)));  ostToMS((AcDbEntity*)pPLine); pPLine->close(); } |