Proe Creo 二次开发之获得草图拷贝

*====================================================================*\
    FUNCTION :    ProUtilSectionInfoCopy
    PURPOSE  :    Copies section defining entities to a new section
        applying translation vector
\*====================================================================*/
ProError ProUtilSectionInfoCopy(ProSection exist_section,
                ProSection new_section,
                ProVector trans_vector)
{
    ProError err;
    ProIntlist ent_ids, new_ent_ids;
    int n_ids,i,j,k;
    ProBoolean is_proj;
    Pro2dEntdef *p_entity;
    ProIntlist dim_ids;
    int n_dim_ids,*p_ent_refs;
    ProSecdimType d_type;
    ProSectionPointType *p_pnt_types;
    int n_refs,new_ent_refs[5],dim_id, tmp_id;
    ProBoolean ref_proj;
    ProVector mid_pnt, d1, d2;
    Pro2dPnt dim_pnt;
    Pro2dPointdef dim_loc;

    err = ProSectionEntityIdsGet(exist_section,&ent_ids,&n_ids);
    TEST_CALL_REPORT("ProSectionEntityIdsGet()",
              "ProUtilSectionCopy()", err, err != PRO_TK_NO_ERROR);

    err = ProArrayAlloc(n_ids,sizeof(ProIntlist),n_ids,
            (ProArray *)&new_ent_ids);
    TEST_CALL_REPORT("ProArrayAlloc()",
              "ProUtilSectionCopy()", err, err != PRO_TK_NO_ERROR);

    for (i=0; i<n_ids; i++)
    {
    err = ProSectionEntityIsProjection(exist_section,ent_ids[i],
                       &is_proj);
        TEST_CALL_REPORT("ProSectionEntityIsProjection()",
              "ProUtilSectionCopy()", err, err != PRO_TK_NO_ERROR);

        if (is_proj == PRO_B_TRUE)
    {
        new_ent_ids[i] = -1;
        continue;
        }

        err = ProSectionEntityGet(exist_section,ent_ids[i],&p_entity);
        TEST_CALL_REPORT("ProSectionEntityGet()",
              "ProUtilSectionCopy()", err, err != PRO_TK_NO_ERROR);

        if (err != PRO_TK_NO_ERROR)
    {
        ProTKPrintf(
        "ProUtilSectionInfoCopy Section Entity Id: %d not suppported\n",
           ent_ids[i]);
        continue;
        }


        err = ProSectionEntityAdd(new_section,p_entity,
                  &new_ent_ids[i]);
        TEST_CALL_REPORT("ProSectionEntityAdd()",
              "ProUtilSectionCopy()", err, err != PRO_TK_NO_ERROR);

        err = ProSectionEntityTranslate(new_section,new_ent_ids[i],
                    trans_vector);
        TEST_CALL_REPORT("ProSectionEntityTranslate()",
              "ProUtilSectionCopy()", err, err != PRO_TK_NO_ERROR);
    }

    err = ProSecdimIdsGet(exist_section,&dim_ids,&n_dim_ids);
    TEST_CALL_REPORT("ProSecdimIdsGet()",
              "ProUtilSectionCopy()", err, err != PRO_TK_NO_ERROR);

    for (i=0; i<n_dim_ids; i++)
    {
    err = ProSecdimTypeGet(exist_section,dim_ids[i],&d_type);
        TEST_CALL_REPORT("ProSecdimTypeGet()",
              "ProUtilSectionCopy()", err, err != PRO_TK_NO_ERROR);

        err = ProSecdimReferencesGet(exist_section,dim_ids[i],
                  &p_ent_refs,&p_pnt_types,&n_refs);
        TEST_CALL_REPORT("ProSecdimReferencesGet()",
              "ProUtilSectionCopy()", err, err != PRO_TK_NO_ERROR);

        ref_proj = PRO_B_FALSE;
        for (j=0; j<n_refs; j++)
    {
        err = ProSectionEntityIsProjection(exist_section,
                   p_ent_refs[j],&is_proj);
            TEST_CALL_REPORT("ProSectionEntityFromProjection()",
              "ProUtilSectionCopy()", err, err != PRO_TK_NO_ERROR);
        if ( is_proj == PRO_B_TRUE )
        {
        ref_proj = PRO_B_TRUE;
        break;
            }
        }

        if (ref_proj == PRO_B_TRUE)
    {
        ref_proj = PRO_B_FALSE;
        continue;
        }

        for (j=0; j<n_refs; j++)
    {
        for (k=0; k<n_ids; k++)
        if ( ent_ids[k] == p_ent_refs[j] )
            break;

        new_ent_refs[j] = new_ent_ids[k];
        }

    err = ProSecdimLocationGet(exist_section, dim_ids[i], dim_loc.pnt);
        TEST_CALL_REPORT("ProSecdimLocationGet",
              "ProUtilSectionCopy()", err, err != PRO_TK_NO_ERROR);

    dim_loc.type = PRO_2D_POINT;
    err = ProSectionEntityAdd(new_section, (Pro2dEntdef*)&dim_loc, &tmp_id);
        TEST_CALL_REPORT("ProSectionEntityAdd",
              "ProUtilSectionCopy()", err, err != PRO_TK_NO_ERROR);

        err = ProSectionEntityTranslate(new_section, tmp_id, trans_vector);
        TEST_CALL_REPORT("ProSectionEntityTranslate()",
              "ProUtilSectionCopy()", err, err != PRO_TK_NO_ERROR);

        err = ProSectionEntityEval(new_section, tmp_id, 0, mid_pnt, d1, d2);
        TEST_CALL_REPORT("ProSectionEntityEval()",
              "ProUtilSectionCopy()", err, err != PRO_TK_NO_ERROR);

        err = ProSectionEntityDelete(new_section, tmp_id);
        TEST_CALL_REPORT("ProSectionEntityDelete()",
              "ProUtilSectionCopy()", err, err != PRO_TK_NO_ERROR);
        dim_pnt[0] = mid_pnt[0];
        dim_pnt[1] = mid_pnt[1];

        err = ProSecdimCreate(new_section,new_ent_refs,
           p_pnt_types,n_refs,d_type,dim_pnt,&dim_id);
        TEST_CALL_REPORT("ProSecdimCreate()",
              "ProUtilSectionCopy()", err, err != PRO_TK_NO_ERROR);
    }

    return(err);
}

 

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值