查看单个帖子
旧 2009-04-16, 12:07 PM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】[arx]如何把一幅图像中所有的图形颜色变成白色

[arx]如何把一幅图像中所有的图形颜色变成白色
[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命令.

楼上的兄弟能给个代码看吗?
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)