|
发表于 2006-10-27 20:24:00
|
显示全部楼层
要对 AcDbBlockTableRecord 中的 ACDB_MODEL_SPACE进行遍历啊
void TEST()
{
// TODO: Implement the command
// 假设 newColor=1(红色)
int newColor=1;
// 取 模型空间=pMS
AcDbBlockTable *pBlockTable;
Acad::ErrorStatus es;
acdbHostApplicationServices()->workingDatabase()->getSymbolTable(pBlockTable,AcDb::kForRead);
AcDbBlockTableRecord *pMS;
pBlockTable->getAt(ACDB_MODEL_SPACE,pMS,AcDb::kForRead);
pBlockTable->close();
// 新建迭代器
AcDbBlockTableRecordIterator *pIter=NULL;
pMS->newIterator(pIter);
if (pIter==NULL)
{
acutPrintf("\n** Error on the newIterator...");
pMS->close();
return;
}
// 遍历迭代器中的 Entity 来 改变颜色
for(pIter->start();!pIter->done();pIter->step())
{
acutPrintf("\n****");
AcDbEntity *pEnt=NULL;
// 得到 Entity=pEnt 为 读
pIter->getEntity(pEnt,AcDb::kForRead);
if(pIter==NULL)
continue;
// 将状态 升级
if(pEnt->upgradeOpen()!=Acad::eOk)
{
acutPrintf("\n** one object can't upgradeOpen");
pEnt->close();
continue;
}
// 改变颜色
es=pEnt->setColorIndex(newColor);
if(es!=Acad::eOk)
acutPrintf("\none object can't change the color");
pEnt->close();
}
delete pIter;
pMS->close();
}
|
|