|
////修改选中实体的颜色
static void TESTchangecolorcmd()
{
ads_name ssname;
////选择多个实体,传递NULL,让用户自己来选
acedSSGet(NULL,NULL,NULL,NULL,ssname);
long len;
acedSSLength(ssname,&len);
CString ss;
ss.Format(_T("已选中%d个实体"),len);
acutPrintf(ss);
ads_name entname;
AcDbObjectId id;
AcDbEntity* ent = NULL;
CString strName;
int nNewColor;
////弹出颜色选择对话框
if(acedSetColorDialog(nNewColor,Adesk::kFalse,256) != IDOK){
return;
}
for(int i=0;i<len;i++)
{
if(acedSSName(ssname, i, entname) == RTNORM)
{
////根据名称得到ID
acdbGetObjectId(id,entname);
////以写模式,根据ID索引到对象,并打开ENTITY
acdbOpenObject(ent,id,AcDb::OpenMode::kForWrite);
strName.Format(_T("%d"),ent->colorIndex());
acutPrintf(_T("\n"));
acutPrintf(strName);
/////如果只限制直线
/*if(ent->isKindOf(AcDbLine::desc())){
acutPrintf(_T("\nfind line"));
ent->setColorIndex(nNewColor);
ent->close();
}*/
ent->setColorIndex(nNewColor);
ent->close();
}
}
acedSSFree(ssname);
} |
|