|
- static void TESTchangecolorcmd()
- {
- ads采用name ssname;
- resbuf strFilter;
- ////只能选择直线对象,构造选择集过滤器,只能选直线
- strFilter.resval.rstring = 采用T("LINE");
- strFilter.rbnext = NULL;
- strFilter.restype = 0;
- ////选择多个实体,传递NULL,让用户自己来选
- if(acedSSGet(NULL,NULL,NULL,&strFilter,ssname) != RTNORM)
- {
- return;
- }
- 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 = SelColor();
- 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);
- ent->setColorIndex(nNewColor);
- ent->close();
- }
- }
- acedSSFree(ssname);
- }
复制代码 |
|