• ObjectARX使用事务简单示例


    		AcDbDatabase *pDb = acDocManager->mdiActiveDocument()->database();
    		
    		if (!pDb)
    		{
    			acutPrintf(_T("
    NullDabase!"));
    			return;
    		}
    		AcTransaction *pTrans = actrTransactionManager->startTransaction();
    		if (!pTrans)
    		{
    			acutPrintf(_T("
    NullTransaction!"));
    			return;
    		}		
    		AcDbObject *pObj = NULL;
    		Acad::ErrorStatus es= pTrans->getObject(pObj,pDb->blockTableId(),AcDb::kForRead);
    		if (Acad::eOk != es || !pObj)
    		{
    			acutPrintf(_T("
    GetObject Error= %s !"),es);
    			actrTransactionManager->abortTransaction();
    			return;
    		}
    		AcDbBlockTable *pBlkTbl = AcDbBlockTable::cast(pObj);
    		if (!pBlkTbl)
    		{
    			acutPrintf(_T("
    Cast Error= %s !"),es);
    			actrTransactionManager->abortTransaction();
    			return;
    		}
    		AcDbObjectId msObjId;
    		es = pBlkTbl->getAt(ACDB_MODEL_SPACE,msObjId);
    		if (Acad::eOk != es)
    		{
    			acutPrintf(_T("
    GetObjId Error= %s !"),es);
    			actrTransactionManager->abortTransaction();
    			return;
    		}
    		es = pTrans->getObject(pObj,msObjId,AcDb::kForWrite);
    		if (Acad::eOk != es || !pObj)
    		{
    			acutPrintf(_T("
    GetObject Error= %s !"),es);
    			actrTransactionManager->abortTransaction();
    			return;
    		}
    		AcDbBlockTableRecord *pTblRcd=AcDbBlockTableRecord::cast(pObj);
    		if (!pTblRcd)
    		{
    			acutPrintf(_T("
    Cast 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();
    
  • 相关阅读:
    强大的可视化利器 Chrome Trace Viewer 使用详解
    gpu与image的来回转换
    close to me
    The Light CHPTRS
    Through Different Eyes
    chromium 术语
    someday
    CHPTRS  Last Chance
    Obvious (Alternate Version) CHPTRS
    基本的英语连读
  • 原文地址:https://www.cnblogs.com/edata/p/15368493.html
Copyright © 2020-2023  润新知