[ARX]如何把一幅图像中所有的图形颜色变成白色
如题Acad::ErrorStatus changeColor(AcDbObjectId entId,Adesk::UInt16 newColor)
{
//打开对象,用于编辑
AcDbEntity *pEntity;
acdbOpenObject(pEntity,entId,AcDb::kForWrite);
//设置新的颜色
pEntity->setColorIndex(newColor);
pEntity->close;
return Acad::eOk;
}
改变一个实体的颜色如上图所示,改变全部的呢?
要对 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();
}
谢谢楼上的兄弟
更简单的方法是用AcedCommandh函数调用AUTOCAD的change命令.
楼上的兄弟能给个代码看吗?
这不是全选就可以了吗?
页:
[1]