tongtong 发表于 2006-10-27 16:18:00

[ARX]如何把一幅图像中所有的图形颜色变成白色

如题

tongtong 发表于 2006-10-27 16:26:00

Acad::ErrorStatus changeColor(AcDbObjectId entId,Adesk::UInt16 newColor)
{
   //打开对象,用于编辑
   AcDbEntity *pEntity;
   acdbOpenObject(pEntity,entId,AcDb::kForWrite);
   //设置新的颜色
   pEntity->setColorIndex(newColor);
   pEntity->close;
   return Acad::eOk;
}
改变一个实体的颜色如上图所示,改变全部的呢?

HuaiYu 发表于 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();
}

tongtong 发表于 2006-10-29 20:23:00

谢谢楼上的兄弟

wzz1968 发表于 2006-10-31 09:48:00

更简单的方法是用AcedCommandh函数调用AUTOCAD的change命令.

tongtong 发表于 2006-11-4 13:33:00

楼上的兄弟能给个代码看吗?

wrw830820 发表于 2012-10-15 10:45:00

这不是全选就可以了吗?
页: [1]
查看完整版本: [ARX]如何把一幅图像中所有的图形颜色变成白色