- 积分
- 5785
- 明经币
- 个
- 注册时间
- 2007-8-16
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
发表于 2015-10-29 08:04:47
|
显示全部楼层
- static void asdkMyGroupMyCommand () {
- // Put your command code here
- resbuf* rb=NULL;
- rb= acutBuildList(RTDXF0, _T("INSERT"),RTNONE);
- int ret;
- ads_name result;
- ret = acedSSGet(NULL, NULL, NULL, rb, result );
- if (ret!= RTNORM)
- {
- acedPrompt( _T("\n创建选择集失败!") );
- return;
- }
- acutRelRb(rb);
- long len,i=0;
- acedSSLength(result,&len);
- AcDbObjectIdArray blkIds;
- Acad::ErrorStatus es;
- ads_name ent;
- AcDbObjectId objId,blkId;
- for(i=0; i<len; i++)
- {
- acedSSName(result, i, ent);
- acdbGetObjectId(objId, ent);
- AcDbEntity *pEnt=NULL;
- es=acdbOpenAcDbEntity(pEnt, objId, AcDb::kForRead,false);
- if (es!=Acad::eOk)
- {
- continue;
- }
- AcDbBlockReference *pBlockRef =NULL;
- pBlockRef = AcDbBlockReference::cast(pEnt);
- blkId=pBlockRef ->blockTableRecord();
- if (!blkIds.contains(blkId,0))
- {
- blkIds.append(blkId);
- }
- pBlockRef->close();
- pEnt->close();
- }
- for (int i=0;i<blkIds.logicalLength();i++)
- {
- AcDbObjectId id=blkIds.at(i);
- AcDbBlockTableRecordPointer btr(id,AcDb::kForWrite,false);
- if (btr.openStatus()!=Acad::eOk)
- {
- continue;
- }
- AcDbBlockTableRecordIterator *pItr=NULL; // 块表记录遍历器;
- btr->newIterator(pItr);
- AcDbEntity *pEn=NULL;
- for (pItr->start(); !pItr->done(); pItr->step())
- {
- pItr->getEntity(pEn, AcDb::kForRead,false);
- if (pEn->isA()==AcDbLine::desc())
- {
- pEn->upgradeOpen();
- pEn->setColorIndex(1,1);
- pEn->close();
- }
- }
- delete pItr;
- btr.close();
- }
- acedCommand(RTSTR,_T("regen"),RTNONE);
- acedSSFree(result);//释放选集
- }
复制代码 |
|