사용 함수 :
ArxSetBlockRefColor(AcDbBlockReference* pBlkRef , const int& colorIndex)
/**
\brief The ArxSetBlockDefColor function
\param objId a parameter of type const AcDbObjectId&
\param colorIndex a parameter of type const int&
\return void
*/
void ArxSetBlockDefColor(const AcDbObjectId& objId , const int& colorIndex)
{
USES_OKEYS;
AcDbBlockTableRecord* pRcd;
try
{
ARXOK(acdbOpenObject(pRcd,objId,AcDb::kForRead));
//////////////////////////////////////////////////////////////////////////
AcDbBlockTableRecordIterator* pIterator;
if(Acad::eOk == pRcd->newIterator(pIterator))
{
for(;pIterator && !pIterator->done();pIterator->step())
{
AcDbEntity* pEnt;
try
{
ARXOK(pIterator->getEntity(pEnt,AcDb::kForWrite));
if(pEnt->isKindOf(AcDbBlockReference::desc()))
{
AcDbObjectId blockId = AcDbBlockReference::cast(pEnt)->blockTableRecord();
pEnt->setColorIndex(colorIndex);
ARXCLOSE(pEnt);
ArxSetBlockDefColor(blockId , colorIndex);
}
else
{
pEnt->setColorIndex(colorIndex);
ARXCLOSE(pEnt);
}
}
catch(const char* ex)
{
ARXERROR(ex);
}
}
delete pIterator;
}
//////////////////////////////////////////////////////////////////////////
ARXCLOSE(pRcd);
}
catch(const char* ex)
{
ARXERROR(ex);
}
}
/**
\brief The ArxSetBlockRefColor function
\param pBlkRef a parameter of type AcDbBlockReference*
\param colorIndex a parameter of type const int&
\return void
*/
void ArxSetBlockRefColor(AcDbBlockReference* pBlkRef , const int& colorIndex)
{
assert(pBlkRef && "pBlkRef is NULL");
if(pBlkRef)
{
AcDbObjectIterator* pItr = pBlkRef->attributeIterator();
if(NULL != pItr)
{
for(;!pItr->done();pItr->step())
{
AcDbObjectId attrId=pItr->objectId();
AcDbObject* pAttr;
try
{
USES_OKEYS;
ARXOK(acdbOpenObject(pAttr,attrId,AcDb::kForWrite));
if(pAttr->isKindOf(AcDbEntity::desc()))
{
AcDbEntity::cast(pAttr)->setColorIndex(colorIndex);
}
ARXCLOSE(pAttr);
}
catch(const char* es)
{
ARXERROR(es);
}
}
delete pItr;
pBlkRef->setColorIndex(colorIndex);
}
AcDbObjectId blockTableRecordId = pBlkRef->blockTableRecord();
ArxSetBlockDefColor(blockTableRecordId , colorIndex);
}
}
댓글
댓글 쓰기