bool test()
{
ads_name ename;
ads_point ptResult;
ads_matrix adsmat;
struct resbuf *info;
// select one entity
int rt = acedNEntSelP(_T("\nselect an entity:"),
ename,
ptResult,
false ,
adsmat,
&info);
if( rt!= RTNORM)
{
acutPrintf(_T("\nFailure in acedNEntSelP"));
return false;
}
AcDbObjectId old__ent_id;
acdbGetObjectId(old__ent_id,ename);
AcDbCircle* newCircle =
new AcDbCircle(
AcGePoint3d(0,0,0),
AcGeVector3d(0,0,1),
10);
// correct usage
AcDbObject *pObj;
Acad::ErrorStatus es1 =
acdbOpenObject(pObj,old__ent_id,AcDb::kForWrite);
if (pObj == NULL)
return false;
Acad::ErrorStatus es =
pObj->handOverTo(newCircle);
if (es ==
Acad::eObjectToBeDeleted)
{
newCircle->close();
delete pObj;
return true;
}
else
{
pObj->close();
return false;
}
// wrong usage: with Transaction
/* AcTransaction *pTrans =
actrTransactionManager->startTransaction();
AcDbObject *pObj;
pTrans->getObject(pObj,
old__ent_id,
AcDb::kForWrite);
if (pObj == NULL)
return false;
// will get eInvalidContext
Acad::ErrorStatus es =
pObj->handOverTo(newCircle);
if (es ==
Acad::eObjectToBeDeleted)
{
delete pObj;
actrTransactionManager->endTransaction();
return true;
}
else
{
actrTransactionManager->abortTransaction();
return false;
}
*/