当前位置: 首页>>代码示例>>C++>>正文


C++ AcDbEntity::setColorIndex方法代码示例

本文整理汇总了C++中AcDbEntity::setColorIndex方法的典型用法代码示例。如果您正苦于以下问题:C++ AcDbEntity::setColorIndex方法的具体用法?C++ AcDbEntity::setColorIndex怎么用?C++ AcDbEntity::setColorIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AcDbEntity的用法示例。


在下文中一共展示了AcDbEntity::setColorIndex方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: asdktest3

void asdktest3 () {
    //----- Create a line and a circle (memory only)
    AcDbLine *pLine =new AcDbLine (AcGePoint3d (), AcGePoint3d (100, 100, -100)) ;
    AcDbCircle *pCircle =new AcDbCircle (AcGePoint3d (50, 50, 0), AcGeVector3d (0, 0, 1) , 25.0) ;

    //----- Create a region from the circle
    AcDbVoidPtrArray arr1, arr2 ;
    arr1.append (pCircle) ;
    AcDbRegion::createFromCurves (arr1, arr2) ;
    AcDbRegion *pRegion =(AcDbRegion *)arr2.at (0) ;
    delete pCircle ;

    //----- Add the line and the region objects to the collector
    //----- NB: Remember those object are memory objects only
    AsdkHlrCollector collector ;
    collector.setDeleteState (true) ;
    collector.addEntity (pLine) ;
    collector.addEntity (pRegion) ;

    //----- Process hidden line removal
    AsdkHlrEngine hlr (AcGePoint3d (50, 50,0), AcGeVector3d (0, 0, 1), kEntity | kBlock | kShowAll | kProject | kHonorInternals) ;
    hlr.run (collector) ;

    //----- To easily see the result, we do append resulting entities to the current database
    //----- and use the color convention used in command 'TEST1'
    int n =collector.mOutputData.logicalLength () ;
    for ( int i =0 ; i < n ; i++ ) {
        AsdkHlrData *p =collector.mOutputData [i] ;

        AcDbEntity *pEnt =p->getResultEntity () ;
        AsdkHlrData::Visibility vis =p->getVisibility () ;
        if ( vis == AsdkHlrData::kVisible )
            pEnt->setColorIndex (1) ;
        else
            pEnt->setColorIndex (5) ;
        AcDbObjectId id ;
        if ( postToDatabase (NULL, pEnt, id) != Acad::eOk ) {
            acutPrintf (_T("Failed to add entity to current space.\n")) ;
            break ;
        }

        //----- Entity originator path
        AcDbObjectIdArray ids =p->getObjectIds () ;
        if ( ids.logicalLength () > 0 ) {
            acutPrintf (ACRX_T("\n%ld, "), pEnt->objectId ().asOldId ()) ;
            for ( int j =0 ; j < ids.logicalLength () ; j++ ) {
                acutPrintf (ACRX_T("%ld, "), ids.at (j).asOldId ()) ;
            }
        }

        pEnt->close () ;
    }
}
开发者ID:FengLuanShuangWu,项目名称:AutoCADPlugin-HeatSource,代码行数:53,代码来源:HlrArxSampleCommands.cpp

示例2:

bool ArxEntityHelper::SetEntitiesColor2( const AcDbObjectIdArray& objIds, const 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::kForWrite ) )
        {
            actrTransactionManager->abortTransaction();
            ret = false;
            break;
        }
        AcDbEntity* pEnt = AcDbEntity::cast( pObj );
        if( pEnt == 0 )
        {
            actrTransactionManager->abortTransaction();
            ret = false;
            break;
        }
        pEnt->setColorIndex( colors[i] ); // 恢复原先的颜色
    }
    actrTransactionManager->endTransaction();
    return ret;
}
开发者ID:kanbang,项目名称:TIDS,代码行数:28,代码来源:ArxEntityHelper.cpp

示例3: SetEntitiesColor

bool ArxEntityHelper::SetEntitiesColor( AcDbObjectIdArray& objIds, unsigned short colorIndex )
{
    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::kForWrite ) )
        {
            actrTransactionManager->abortTransaction();
            ret = false;
            break;
        }

        AcDbEntity* pGE = AcDbEntity::cast( pObj );
        if( pGE == 0 )
        {
            actrTransactionManager->abortTransaction();
            ret = false;
            break;
        }

        // 设置颜色
        pGE->setColorIndex( colorIndex );
    }
    actrTransactionManager->endTransaction();

    return ret;
}
开发者ID:kanbang,项目名称:TIDS,代码行数:32,代码来源:ArxEntityHelper.cpp

示例4: SetEntityColor

bool ArxEntityHelper::SetEntityColor( const AcDbObjectId& objId, unsigned short colorIndex )
{
    AcTransaction* pTrans = actrTransactionManager->startTransaction();
    if( pTrans == 0 ) return false;

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

    AcDbEntity* pGE = AcDbEntity::cast( pObj );
    if( pGE == 0 )
    {
        actrTransactionManager->abortTransaction();
        return false;
    }

    // 设置颜色
    pGE->setColorIndex( colorIndex );
    actrTransactionManager->endTransaction();
    return true;
}
开发者ID:kanbang,项目名称:TIDS,代码行数:24,代码来源:ArxEntityHelper.cpp

示例5: asdktest1

void asdktest1 () {
    //----- Select the entities
    ads_name ss, en ;
    if ( acedSSGet (NULL, NULL, NULL, NULL, ss) != RTNORM )
        return ;

    //----- Append entity IDs to the collector
    long n ;
    AcDbObjectId id ;
    AsdkHlrCollector collector ;
    collector.setDeleteState (true) ;
    acedSSLength (ss, &n) ;
    for ( int i =0 ; i < n ; i++ ) {
        acedSSName (ss, i, en) ;
        acdbGetObjectId (id, en) ;
        collector.addEntity (id) ;
    }
    acedSSFree (ss) ;

    //----- Get current viewport settings
    struct resbuf rb;
    acedGetVar(ACRX_T(/*NOXLATE*/"viewdir"), &rb);
    ads_point dirPt;
    acdbUcs2Wcs (rb.resval.rpoint, dirPt, Adesk::kTrue) ;
    acedGetVar(ACRX_T(/*NOXLATE*/"target"), &rb);
    ads_point tarPt;
    acdbUcs2Wcs (rb.resval.rpoint, tarPt, Adesk::kFalse) ;

    //----- Ask if non-visible edges should be created
    int hidLines =AfxMessageBox (ACRX_T("Would you like to see hidden lines?"), MB_YESNO) ;
    int honorInt =AfxMessageBox (ACRX_T("Would you like to honor internal visibility of polyface meshes or ACIS objects?"), MB_YESNO) ;
    int meshSils =AfxMessageBox (ACRX_T("Would you like to calculate silhouettes of polyface meshes?"), MB_YESNO) ;
    int unit =AfxMessageBox (ACRX_T("Would you like to unit solid before processing?"), MB_YESNO) ;

    //----- Process hidden line removal
    AsdkHlrEngine hlr (
        asPnt3d (tarPt), asVec3d (dirPt),
        kEntity | kBlock | kSubentity | kProgress
        | (honorInt == IDYES ? kHonorInternals : 0)
        | (hidLines == IDYES ? kShowAll : 0)
        | (meshSils == IDYES ? kMeshSilhouettes : 0)
        | (unit == IDYES ? kUnite : 0)
    ) ;
    hlr.setAcisConversionProgressCallBack (progress1) ;
    hlr.setAhlProgressCallBack (progress2) ;
    hlr.setAcadConversionProgressCallBack (progress3) ;

    acedSetStatusBarProgressMeter (ACRX_T("HLR running: "), 0, 300) ;
    hlr.run (collector) ;
    acedRestoreStatusBar () ;

    //----- Assign color to the resulting entities
    //----- red for visible edges
    //----- blue for non-visible edges
    //----- yellow for internal edges
    n =collector.mOutputData.logicalLength () ;
    for (int i =0 ; i < n ; i++ ) {
        AsdkHlrData *p =collector.mOutputData [i] ;

        AcDbEntity *pEnt =p->getResultEntity () ;
        AsdkHlrData::Visibility vis =p->getVisibility () ;
        if ( vis == AsdkHlrData::kVisible ) {
            pEnt->setColorIndex (1) ; //----- Read
        } else if ( vis == AsdkHlrData::kInternallyHidden ) {
            if ( p->getHlrVisibility () == AsdkHlrData::kVisible )
                pEnt->setColorIndex (2) ; //----- Yellow
            else
                pEnt->setColorIndex (3) ; //----- Green
        } else {
            pEnt->setColorIndex (5) ; //----- Blue
        }

        if ( postToDatabase (NULL, pEnt, id) != Acad::eOk ) {
            acutPrintf (_T("Failed to add entity to current space.\n")) ;
            break ;
        }
        if ( acdbOpenAcDbEntity (pEnt, id, AcDb::kForRead) != Acad::eOk ) {
            acutPrintf (_T("Failed to open last added outputed curve.\n")) ;
            break ;
        }

        //----- Entity originator path for block reference entities
        AcDbObjectIdArray ids =p->getObjectIds () ;
        if ( ids.logicalLength () > 0 ) {
            acutPrintf (ACRX_T("\n%lx, "), pEnt->objectId ().asOldId ()) ;
            if ( p->getSubentId ().type () != AcDb::kNullSubentType )
                acutPrintf (ACRX_T("[%ld, %ld], "), p->getSubentId ().type (), p->getSubentId ().index ()) ;
            for ( int j =0 ; j < ids.logicalLength () ; j++ )
                acutPrintf (ACRX_T("%lx, "), ids.at (j).asOldId ()) ;
            AcDbObjectId id =ids.last () ;
            if ( !id.isNull () ) {
                AcDbEntity *ent =NULL ;
                acdbOpenAcDbEntity (ent, id, AcDb::kForRead) ;
                id =ent->linetypeId () ;
                ent->close () ;
                if ( pEnt->upgradeOpen () == Acad::eOk )
                pEnt->setLinetype (id) ;
            }
        }

//.........这里部分代码省略.........
开发者ID:FengLuanShuangWu,项目名称:AutoCADPlugin-HeatSource,代码行数:101,代码来源:HlrArxSampleCommands.cpp

示例6: AddEntityToLayer

// This command demonstrates the use of kCleanup / kReuse flags
void AddEntityToLayer (AsdkHlrCollector &collector, ACHAR *layerName) {
    //----- Check layer
    if ( layerName != NULL && *layerName != ACRX_T('\0') ) {
        AcDbDatabase *pDb =acdbHostApplicationServices ()->workingDatabase () ;
        AcDbLayerTable *pLayerTable ;
        pDb->getLayerTable (pLayerTable, AcDb::kForRead) ;
        if ( !pLayerTable->has (layerName) ) {
            AcDbLayerTableRecord *pLayerRecord =new AcDbLayerTableRecord ;
            pLayerRecord->setName (layerName) ;
            pLayerTable->upgradeOpen () ;
            pLayerTable->add (pLayerRecord) ;
            pLayerTable->downgradeOpen () ;
            pLayerRecord->close () ;
            pLayerTable->close () ;
            applyCurDwgLayerTableChanges () ;
        } else {
            pLayerTable->close () ;
        }
    } else {
        layerName =NULL ;
    }
    //----- Assign color to the resulting entities
    //----- red for visible edges
    //----- blue for non-visible edges
    //----- yellow for internal edges
    int n =collector.mOutputData.logicalLength () ;
    for ( int i =0 ; i < n ; i++ ) {
        AsdkHlrData *p =collector.mOutputData [i] ;

        AcDbEntity *pEnt =p->getResultEntity () ;
        AsdkHlrData::Visibility vis =p->getVisibility () ;
        if ( vis == AsdkHlrData::kVisible ) {
            pEnt->setColorIndex (1) ; //----- Read
        } else if ( vis == AsdkHlrData::kInternallyHidden ) {
            if ( p->getHlrVisibility () == AsdkHlrData::kVisible )
                pEnt->setColorIndex (2) ; //----- Yellow
            else
                pEnt->setColorIndex (3) ; //----- Green
        } else {
            pEnt->setColorIndex (5) ; //----- Blue
        }
        if ( layerName != NULL )
            pEnt->setLayer (layerName) ;
        AcDbObjectId id ;
        if ( postToDatabase (NULL, pEnt, id) != Acad::eOk ) {
            acutPrintf (_T("Failed to add entity to current space.\n")) ;
            break ;
        }

        //----- Entity originator path for block reference entities
        AcDbObjectIdArray ids =p->getObjectIds () ;
        if ( ids.logicalLength () > 0 ) {
            acutPrintf (ACRX_T("\n%ld, "), pEnt->objectId ().asOldId ()) ;
            for ( int j =0 ; j < ids.logicalLength () ; j++ ) {
                acutPrintf (ACRX_T("%ld, "), ids.at (j).asOldId ()) ;
            }
        }

        pEnt->close () ;
    }
}
开发者ID:FengLuanShuangWu,项目名称:AutoCADPlugin-HeatSource,代码行数:62,代码来源:HlrArxSampleCommands.cpp

示例7: acutNewRb


//.........这里部分代码省略.........

    // Set up an object ID array.
    //
    AcDbObjectIdArray objIdArray;

    // Iterate over the model space BTR. Look specifically 
    // for lines and append their object ID to the array.
    //
    for (pIter->start(); !pIter->done(); pIter->step()) {
        AcDbEntity *pEntity;
        pIter->getEntity(pEntity, AcDb::kForRead);

        // Look for only AcDbLine objects and add them to the 
        // object ID array.
        //
        if (pEntity->isKindOf(AcDbLine::desc())) {
            objIdArray.append(pEntity->objectId());
        }
        pEntity->close();
    }
    delete pIter;
    pOtherMsBtr->close();

    if (objIdArray.isEmpty()) {
        acad_free(fname);
        acutPrintf("\nYou must pick a drawing file that contains lines.");
        return;
    }

    // Now get the current database and the object ID for the
    // current database's model space BTR.
    //
    AcDbBlockTable *pThisBlockTable;
    acdbHostApplicationServices()->workingDatabase()
        ->getSymbolTable(pThisBlockTable, AcDb::kForRead);

    AcDbBlockTableRecord *pThisMsBtr;
    pThisBlockTable->getAt(ACDB_MODEL_SPACE, pThisMsBtr, AcDb::kForWrite);
    pThisBlockTable->close();
    
    AcDbObjectId id = pThisMsBtr->objectId();
    pThisMsBtr->close();


    // Create the long transaction. This will check all the entities 
    // out of the external database.
    //
    AcDbIdMapping errorMap;
    acapLongTransactionManagerPtr()->checkOut(transId, objIdArray, id, errorMap);

    // Now modify the color of these entities.
    //
    int colorIndex;
    acedGetInt("\nEnter color number to change entities to: ", &colorIndex);
    AcDbObject* pObj;
    if (acdbOpenObject(pObj, transId, AcDb::kForRead) == Acad::eOk) {

        // Get a pointer to the transaction.
        //
        AcDbLongTransaction* pLongTrans = AcDbLongTransaction::cast(pObj);
        if (pLongTrans != NULL) {

            // Get a work set iterator.
            //
            AcDbLongTransWorkSetIterator* pWorkSetIter;
            pLongTrans->newWorkSetIterator(pWorkSetIter);

            // Iterate over the entities in the work set and change the color.
            //
            for (pWorkSetIter->start(); !pWorkSetIter->done(); pWorkSetIter->step()) {
                AcDbEntity *pEntity;
                acdbOpenAcDbEntity(pEntity, pWorkSetIter->objectId(), AcDb::kForWrite);
                pEntity->setColorIndex(colorIndex);
                pEntity->close();
            }
            delete pWorkSetIter;
        }
        pObj->close();
    }

    // Pause to see the change.
    //
    char str[132];
    acedGetString(0, "\nSee the new colors. Press return to check the object into the original database", str);

    // Check the entities back in to the original database.
    //
    acapLongTransactionManagerPtr()->checkIn(transId, errorMap);

    // Save the original database, since we have made changes.
    //
    pDb->saveAs(fname);

    // Close/Delete the database
    //
    delete pDb;
    pDb = NULL;

    acad_free(fname);
}
开发者ID:kevinzhwl,项目名称:ObjectARXMod,代码行数:101,代码来源:AsdkLongTransSample.cpp


注:本文中的AcDbEntity::setColorIndex方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。