|
[code][code]static void MyGroupTestTrans() {
AcDbObjectId id;
AcDbObject *pObj1 = nullptr, *pObj2 = nullptr;
Acad::ErrorStatus es;
// создать объект AcDbLine с фиксированными координатами начала и конца
AcDbDatabase *pCurDb = acdbHostApplicationServices()->workingDatabase();
AcDbBlockTable *pBlockTable = nullptr;
pCurDb->getSymbolTable(pBlockTable, AcDb::kForRead);
AcDbBlockTableRecord *pModelSpace = nullptr;
pBlockTable->getAt(ACDB_MODEL_SPACE, pModelSpace, AcDb::kForWrite);
pBlockTable->close();
AcGePoint3d startPt(0.0, 0.0, 0.0), endPt(2000.0, 1000.0, 0.0);
AcDbLine *pLine = new AcDbLine(startPt, endPt);
pModelSpace->appendAcDbEntity(id, pLine);
pLine->close();
pModelSpace->close();
// открытие объекта через транзакции
AcTransaction *pTrans1 = actrTransactionManager->startTransaction();
es = pTrans1->getObject(pObj1, id, AcDb::kForWrite, false);
if (es != Acad::eOk)
acutPrintf(L"pTrans1->getObject() ErrorStatus = %s\n", acadErrorStatusText(es));
AcTransaction *pTrans2 = actrTransactionManager->startTransaction();
es = pTrans2->getObject(pObj2, id, AcDb::kForNotify, false);
if (es != Acad::eOk)
acutPrintf(L"pTrans2->getObject() ErrorStatus = %s\n", acadErrorStatusText(es));
es = actrTransactionManager->endTransaction();
es = actrTransactionManager->endTransaction();
//////////////////////////////////////////////////////////////////////////
// Используем новые интеллектуальные указатели
//////////////////////////////////////////////////////////////////////////
AcDbSmartObjectPointer<AcDbEntity> pEnt(id, AcDb::OpenMode::kForWrite);
if ((es = pEnt.openStatus()) == Acad::eOk)
{
pEnt->erase(Adesk::kTrue);
}
else
{
acutPrintf(L"pEnt.openStatus() ErrorStatus = %s\n", acadErrorStatusText(es));
}
}[/code][/code] |
|