示例#1
0
bool ArxEntityHelper::GetEntitiesColor( const AcDbObjectIdArray& objIds, AcArray<Adesk::UInt16>& colors )
{
    AcTransaction* pTrans = actrTransactionManager->startTransaction();
    if( pTrans == 0 ) return false;

    bool ret = true;  // 默认返回true
    int len = objIds.length();
    for( int i = 0; i < len; i++ )
    {
        AcDbObject* pObj;
        if( Acad::eOk != pTrans->getObject( pObj, objIds[i], AcDb::kForRead ) )
        {
            actrTransactionManager->abortTransaction();
            ret = false;
            colors.removeAll(); // 清空
            break;
        }
        AcDbEntity* pEnt = AcDbEntity::cast( pObj );
        if( pEnt == 0 )
        {
            actrTransactionManager->abortTransaction();
            ret = false;
            colors.removeAll(); // 清空
            break;
        }
        Adesk::UInt16 ci = pEnt->colorIndex();
        colors.append( ci ); // 记录原有的颜色
    }
    actrTransactionManager->endTransaction();
    return ret;
}
示例#2
0
bool ArxEntityHelper::GetEntityColor( const AcDbObjectId& objId, Adesk::UInt16& colorIndex )
{
    AcTransaction* pTrans = actrTransactionManager->startTransaction();
    if( pTrans == 0 ) return false;

    AcDbObject* pObj;
    if( Acad::eOk != pTrans->getObject( pObj, objId, AcDb::kForRead ) )
    {
        actrTransactionManager->abortTransaction();
        return false;
    }
    AcDbEntity* pEnt = AcDbEntity::cast( pObj );
    if( pEnt == 0 )
    {
        actrTransactionManager->abortTransaction();
        return false;
    }

    colorIndex = pEnt->colorIndex();
    actrTransactionManager->endTransaction();

    return true;
}