|
[code]AcDbDatabase *pDb = acDocManager->mdiActiveDocument()->database();
if (!pDb)
{
acutPrintf(_T("\nNullDabase!"));
return;
}
AcTransaction *pTrans = actrTransactionManager->startTransaction();
if (!pTrans)
{
acutPrintf(_T("\nNullTransaction!"));
return;
}
AcDbObject *pObj = NULL;
Acad::ErrorStatus es= pTrans->getObject(pObj,pDb->blockTableId(),AcDb::kForRead);
if (Acad::eOk != es || !pObj)
{
acutPrintf(_T("\nGetObject Error= %s !"),es);
actrTransactionManager->abortTransaction();
return;
}
AcDbBlockTable *pBlkTbl = AcDbBlockTable::cast(pObj);
if (!pBlkTbl)
{
acutPrintf(_T("\nCast Error= %s !"),es);
actrTransactionManager->abortTransaction();
return;
}
AcDbObjectId msObjId;
es = pBlkTbl->getAt(ACDB_MODEL_SPACE,msObjId);
if (Acad::eOk != es)
{
acutPrintf(_T("\nGetObjId Error= %s !"),es);
actrTransactionManager->abortTransaction();
return;
}
es = pTrans->getObject(pObj,msObjId,AcDb::kForWrite);
if (Acad::eOk != es || !pObj)
{
acutPrintf(_T("\nGetObject Error= %s !"),es);
actrTransactionManager->abortTransaction();
return;
}
AcDbBlockTableRecord *pTblRcd=AcDbBlockTableRecord::cast(pObj);
if (!pTblRcd)
{
acutPrintf(_T("\nCast Error= %s !"),es);
actrTransactionManager->abortTransaction();
return;
}
AcDbLine *pLine = new AcDbLine(AcGePoint3d(0,0,0),AcGePoint3d(500,0,0));
pLine->setColorIndex(1);
pTblRcd->appendAcDbEntity(pLine);
actrTransactionManager->addNewlyCreatedDBRObject(pLine,true);
actrTransactionManager->endTransaction();[/code] |
|