zoukankan      html  css  js  c++  java
  • Objectarx之分批存储相连实体

    void CCommonFuntion::BatchStorageEnt(AcDbObjectIdArray& inputId, std::vector<std::vector<AcDbObjectId>>& outputId)
    {
    AcDbEntity *pEnt = NULL;
    AcDbEntity *tempEnt = NULL;
    if (inputId.length() == 1)
    {
    std::vector<AcDbObjectId> tempcompare;
    tempcompare.push_back(inputId[0]);
    outputId.push_back(tempcompare);
    }
    else
    {
    for (int i = 0; i < inputId.length(); i++)
    {
    bool tag = true;

    if (Acad::eOk != acdbOpenObject(pEnt, inputId[i], AcDb::kForRead))
    continue;

    for (int j = 0; j < inputId.length(); j++)
    {

    std::vector<AcDbObjectId> tempcompare;
    if (inputId[i] == inputId[j])
    continue;
    if (Acad::eOk != acdbOpenObject(tempEnt, inputId[j], AcDb::kForRead))
    continue;

    AcGePoint3dArray intersectPoints;
    tempEnt->intersectWith(pEnt, AcDb::kOnBothOperands, intersectPoints);
    if (intersectPoints.length() > 0)
    {
    tag = false;
    bool ent_tag = true;
    int ent_num = 0;
    for (int k = 0; k < outputId.size(); k++)
    {
    if (std::find(outputId[k].begin(), outputId[k].end(), inputId[i]) != outputId[k].end())//存在实体ID
    {

    ent_tag = false;
    ent_num = k;
    break;
    }
    }

    bool tement_tag = true;
    int tempent_num = 0;
    for (int k = 0; k < outputId.size(); k++)
    {
    if (std::find(outputId[k].begin(), outputId[k].end(), inputId[j]) != outputId[k].end())//存在实体ID
    {

    tement_tag = false;
    tempent_num = k;
    break;
    }
    }

    if (ent_tag)
    {
    if (tement_tag)
    {
    tempcompare.push_back(inputId[i]);
    tempcompare.push_back(inputId[j]);
    outputId.push_back(tempcompare);
    }
    else
    outputId[tempent_num].push_back(inputId[i]);
    }
    else
    {
    if (tement_tag)
    outputId[ent_num].push_back(inputId[j]);
    else
    {
    if (tempent_num != ent_num)
    {
    for (int Num = 0; Num < outputId[tempent_num].size(); Num++)
    {
    outputId[ent_num].push_back(outputId[tempent_num][Num]);
    }
    std::remove(outputId.begin(), outputId.end(), outputId[tempent_num]);
    }
    }
    }
    }
    if (tempEnt)
    tempEnt->close();
    }
    if (tag)
    {
    std::vector<AcDbObjectId> tempvector;
    tempvector.push_back(inputId[i]);
    outputId.push_back(tempvector);
    }

    if (pEnt)
    pEnt->close();
    }
    }
    }

  • 相关阅读:
    react条件渲染
    js用replaceAll全部替换的方法
    批量重命名图片,去除括号
    [转]自定义alert弹框,title不显示域名
    [转]ASCII码表及扩展ASCII码表,方便查阅
    [转]PHP中file_put_contents追加和换行
    Response
    Redirect
    Request
    Paginator
  • 原文地址:https://www.cnblogs.com/Pond-ZZC/p/11813590.html
Copyright © 2011-2022 走看看