zoukankan      html  css  js  c++  java
  • 检查所有实体的编号是否重复

    //在cad画图中经常为遇到需要对实体进行编号的操作,这样就会存在可能因为认为操作而导致的编号重复的问题,

       这样就需要程序有自动检测编号是否重复的问题,此代码是根据自己所做的项目进行编写的,所以不能使用与所有的

       代码中,但思路可以借鉴。

    //检查所有实体的编号是否有重复部分
    void SignRepetition()
    {
    AcDbObjectIdArray entIds = ObtainEntId();
    int count = 0;
    //遍历每个Id对应实体的扩展数据看是否存在相同的
    for (int i = 0; i < (entIds.length()-1); i++)
    {
    AcDbEntity *pEnt1;
    resbuf *pBuf1;
    Acad::ErrorStatus es = acdbOpenObject(pEnt1, entIds[i], ZcDb::kForRead);
    if ( Acad::eOk != es )
    {
    acutPrintf(_T(" 打开实体失败!"));
    return;
    }
    pBuf1 = pEnt1->xData(_T("BMC_NO_APP"));
    resbuf *buf1;
    buf1 = pBuf1;
    buf1 = buf1->rbnext;
    for (int j = i+1; j < entIds.length(); j++)
    {
    AcDbEntity *pEnt2;
    resbuf *pBuf2;
    Acad::ErrorStatus es = acdbOpenObject(pEnt2, entIds[j], ZcDb::kForRead);
    if ( Acad::eOk != es )
    {
    acutPrintf(_T(" 打开实体失败!"));
    return;
    }
    pBuf2 = pEnt2->xData(_T("BMC_NO_APP"));
    resbuf *buf2;
    buf2 = pBuf2;
    buf2 = buf2->rbnext;
    CString str1 = buf1->resval.rstring;
    CString str2 = buf2->resval.rstring;
    if ( str1 == str2 )
    {
    acutPrintf(_T(" 编号错误,有实体编号相同!"));
    SignEnt(entIds[i]);
    SignEnt(entIds[j]);
    ++count;
    }
    pEnt2->close();
    acutRelRb(pBuf2);
    }
    pEnt1->close();
    acutRelRb(pBuf1);
    }
    if ( count== 0 )
    {
    acutPrintf(_T(" 没有重复的编号!"));
    }
    else
    {
    acutPrintf(_T(" 有实体编号相同,已用圆标记!"));
    }
    }

  • 相关阅读:
    如何安装配置ulipad
    python链接mysql的代码
    python 模块
    python 查找关键词在百度的排名
    python 类和对象
    python beautifulsoup多线程分析抓取网页
    python 函数关键参数
    python 批量下载文件
    python 语言有哪些特点
    python 类和对象的特点
  • 原文地址:https://www.cnblogs.com/pengjun-shanghai/p/4786363.html
Copyright © 2011-2022 走看看