OBJECT ARX 修改选中实体的颜色 选择集的使用

来源:互联网 发布:琅琊榜捏脸数据 编辑:程序博客网 时间:2024/06/03 23:41
[cpp] view plain copy
 print?
  1. ////修改选中实体的颜色  
  2. static void TESTchangecolorcmd(){  
  3.   
  4. ads_name ssname;  
  5. ////选择多个实体,传递NULL,让用户自己来选  
  6. acedSSGet(NULL,NULL,NULL,NULL,ssname);  
  7. long len;  
  8. acedSSLength(ssname,&len);  
  9. CString ss;  
  10. ss.Format(_T("已选中%d个实体"),len);  
  11. acutPrintf(ss);  
  12.   
  13.   
  14. ads_name entname;  
  15.   
  16.   
  17. AcDbObjectId id;  
  18. AcDbEntity* ent = NULL;  
  19. CString strName;  
  20.   
  21.   
  22. int nNewColor;  
  23. ////弹出颜色选择对话框  
  24. if(acedSetColorDialog(nNewColor,Adesk::kFalse,256) != IDOK){  
  25. return;  
  26. }  
  27.   
  28.   
  29. for(int i=0;i<len;i++)  
  30. {  
  31.   
  32.   
  33. if(acedSSName(ssname, i, entname) == RTNORM)  
  34. {  
  35.   
  36.   
  37. ////根据名称得到ID  
  38. acdbGetObjectId(id,entname);  
  39.   
  40.   
  41. ////以写模式,根据ID索引到对象,并打开ENTITY  
  42. acdbOpenObject(ent,id,AcDb::OpenMode::kForWrite);  
  43. strName.Format(_T("%d"),ent->colorIndex());  
  44. acutPrintf(_T("\n"));  
  45. acutPrintf(strName);  
  46.   
  47.   
  48. /////如果只限制直线  
  49. /*if(ent->isKindOf(AcDbLine::desc())){ 
  50.  
  51.  
  52. acutPrintf(_T("\nfind line")); 
  53. ent->setColorIndex(nNewColor); 
  54. ent->close(); 
  55. }*/  
  56.   
  57. ent->setColorIndex(nNewColor);  
  58. ent->close();  
  59. }  
  60. }  
  61.   
  62.   
  63. acedSSFree(ssname);  
  64.   
  65.   
  66.   
  67. }  
0 0