Exemplo n.º 1
0
// 使用常规的Open/Close机制
static void UpdateEntity2( const AcDbObjectId& objId )
{
    AcDbEntity* pEnt;
    if( Acad::eOk != acdbOpenObject( pEnt, objId, AcDb::kForWrite ) ) return;

    pEnt->recordGraphicsModified( true ); // 标签图元状态已修改,需要更新图形
    pEnt->close();
}
Exemplo n.º 2
0
// 使用事务
static void UpdateEntity1( const AcDbObjectId& objId )
{
    AcTransaction* pTrans = actrTransactionManager->startTransaction();
    if( pTrans == 0 ) return;

    AcDbObject* pObj;
    if( Acad::eOk != pTrans->getObject( pObj, objId, AcDb::kForWrite ) ) // 打开图元失败
    {
        actrTransactionManager->abortTransaction();
        return;
    }
    AcDbEntity* pEnt = AcDbEntity::cast( pObj );
    if( pEnt == 0 )
    {
        actrTransactionManager->abortTransaction();
        return;
    }
    pEnt->recordGraphicsModified( true ); // 标签图元状态已修改,需要更新图形
    actrTransactionManager->endTransaction();
}