|
- acDocManager->lockDocument(acDocManager->curDocument());
- CDwgDatabaseUtil::setVar(采用T("cmdecho"), 0); // 关闭回显
- acedCommand(RTSTR, 采用T("undo"), RTSTR, 采用T("be"), RTNONE);
- ads采用name ssName;
- int rt = acedSSGet(采用T("X"), NULL, NULL, NULL, ssName);
- if (rt != RTNORM)
- {
- return;
- }
- std::vector<CString> ssentVec;
- long length;
- acedSSLength(ssName, &length);
- acedSetStatusBarProgressMeter(采用T("◎正在删除重覆实体,等稍等!"), 0, 100);
- DWORD dwCount = ::GetTickCount();
- for (int i = 0; i < length; i++)
- {
- // 100毫秒更新一次
- if(::GetTickCount() - dwCount > 100)
- {
- acedSetStatusBarProgressMeterPos((int) (i * 100.0 / length));
- dwCount = ::GetTickCount();
- }
- ads采用name ent;
- acedSSName(ssName, i, ent);
- struct resbuf *rbEnt; // 保存实体数据的结果缓冲区
- struct resbuf *rb; // 用于遍历rbEnt的结果缓冲区
- rbEnt = acdbEntGet(ent); // 从entName获得保存实体数据的结果缓冲区
- rb = rbEnt;
- CString entname, typa, s10Ptx, s10Pty, s10Ptz, s11Ptx, s11Pty, s11Ptz, svNum;
- std::vector<CString> entVec;
- while (rb != NULL)
- {
- switch (rb->restype)
- {
- case 0: // 对象类型
- typa.Format(采用T("%s"), rb->resval.rstring);
- entVec.push采用back(typa);
- break;
- case 10: // 起点(顶点)坐标
- s10Ptx.Format(采用T("%.2f"), rb->resval.rpoint[X]);
- s10Pty.Format(采用T("%.2f"), rb->resval.rpoint[Y]);
- s10Ptz.Format(采用T("%.2f"), rb->resval.rpoint[Z]);
- entVec.push采用back(s10Ptx);
- entVec.push采用back(s10Pty);
- entVec.push采用back(s10Ptz);
- break;
- case 11: // 终点坐标
- s11Ptx.Format(采用T("%.2f"), rb->resval.rpoint[X]);
- s11Pty.Format(采用T("%.2f"), rb->resval.rpoint[Y]);
- s11Ptz.Format(采用T("%.2f"), rb->resval.rpoint[Z]);
- entVec.push采用back(s11Ptx);
- entVec.push采用back(s11Pty);
- entVec.push采用back(s11Ptz);
- break;
- case 93: // 顶点数目
- svNum.Format(采用T("%f"), rb->resval.rreal);
- entVec.push采用back(svNum);
- break;
- default:
- break;
- }
- rb = rb->rbnext; // 切换到下一个节点
- }
- if (rbEnt != NULL)
- {
- acutRelRb(rbEnt);
- }
- CString entVeclist = CStringUtil::Join(entVec, 采用T(","));
- ssentVec.push采用back(entVeclist);
- }
- acedRestoreStatusBar();
- CString fistNaem = ssentVec[0]; // 首个
- ssentVec.erase(ssentVec.begin()); // 删除第一元素
- int index = 0;
- int len = ssentVec.size();
- int num = 0;
- while (len > 0)
- {
- for (int i = 0; i < ssentVec.size(); i++)
- {
- CString temp = ssentVec<i>;
- if (采用tcscmp(fistNaem, temp) == 0)
- {
- ads采用name ent;
- acedSSName(ssName, num, ent);
- AcDbObjectId entId;
- acdbGetObjectId(entId, ent);
- CEntityUtil::Erase(entId);
- index++;
- }
- }
- num = num + 1;
- fistNaem = ssentVec[0];
- ssentVec.erase(ssentVec.begin());
- len = ssentVec.size();
- }
- acedSSFree(ssName);
- acutPrintf(采用T("\n共删除 %d 个重覆物体"), index);
- acDocManager->unlockDocument(acDocManager->curDocument());
复制代码 |
|