QQ登录

只需一步,快速开始

快捷登录

登录 或者 注册 请先

UG爱好者

查看: 1672|回复: 0
打印 上一主题 下一主题

[原创] 多级序号与所属装配显示;物料号的显示。

[复制链接]

上等兵

Rank: 1

2

主题

12

帖子

129

积分
跳转到指定楼层
楼主
发表于 2016-4-25 18:19:34 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 kylincy 于 2016-4-25 18:33 编辑

由于公司的产品BOM要有“所属装配”一栏,proe又没有相关参数能读取上层组件的图号,在网上搜了好久也没能找到相似的关系式,所以只能借用前辈的代码来改了,我所修改的代码如下:(将下面的代码复制到BOM清单的重复区域内的关系中)
  1. /*多级序号与所属装配显示
  2. if save_idx==pass_num && rpt_index==1
  3.    save_idx=0
  4. endif

  5. if rpt_index>save_idx
  6.    save_idx=rpt_index
  7.    pass_num=0
  8. else
  9.    pass_num=save_idx
  10. endif

  11. if pass_num==0
  12. totalmass=rpt_qty*asm_mbr_mczl /*自定义重量参数

  13. if rpt_index==1
  14.   if exists("asm_mbr_tuhao") /*检查自定义“tuhao”参数
  15.    atuhao=asm_mbr_tuhao /*如果有,将第一层组件的图号提取到"atuhao"中
  16. else
  17.    atuhao="父项无图号" /*如果无,提示父项无图号,以下相同。
  18.   endif
  19.    current_level=rpt_level
  20.    save_2sn=0
  21.    save_3sn=0
  22.    save_4sn=0
  23.    save_5sn=0
  24.    /*加入点
  25. endif

  26. if current_level==rpt_level
  27.     if rpt_level==2
  28.          if exists("asm_mbr_tuhao") /*检查“tuhao”参数
  29.             btuhao=asm_mbr_tuhao /*将第二层的图号提取到"btuhao"中
  30.          else
  31.             btuhao="父项无图号"
  32.          endif
  33.       futuhao=atuhao /*第二层的父图号等于第一层的图号
  34.       save_2sn=save_2sn+1
  35.    endif
  36.    if rpt_level==3
  37.          if exists("asm_mbr_tuhao") /*检查“tuhao”参数
  38.             ctuhao=asm_mbr_tuhao /*将第三层的图号提取到"ctuhao"中
  39.          else
  40.             ctuhao="父项无图号"
  41.          endif
  42.       futuhao=btuhao /*第三层的父图号等于第二层的图号
  43.       save_3sn=save_3sn+1
  44.    endif
  45.    if rpt_level==4
  46.          if exists("asm_mbr_tuhao") /*检查“tuhao”参数
  47.             dtuhao=asm_mbr_tuhao /*将第4层的图号提取到"dtuhao"中
  48.          else
  49.             dtuhao="父项无图号"
  50.          endif
  51.       futuhao=ctuhao /*第4层的父图号等于第3层的图号
  52.       save_4sn=save_4sn+1
  53.    endif
  54.    if rpt_level==5
  55.          if exists("asm_mbr_tuhao") /*检查“tuhao”参数
  56.             etuhao=asm_mbr_tuhao /*将第5层的图号提取到"etuhao"中
  57.          else
  58.             etuhao="父项无图号"
  59.          endif
  60.       futuhao=dtuhao /*第5层的父图号等于第4层的图号
  61.       save_5sn=save_5sn+1
  62.    endif
  63.    /*加入点
  64. else      
  65.    if rpt_level==2
  66.       save_2sn=save_2sn+1
  67.       /*save_4sn=save_2sn
  68.          if exists("asm_mbr_tuhao") /*检查“tuhao”参数
  69.             btuhao=asm_mbr_tuhao /*将第二层的图号提取到"btuhao"中
  70.          else
  71.             btuhao="父项无图号"
  72.          endif
  73.       futuhao=atuhao /*第二层的父图号等于第一层的图号
  74.    endif
  75.    if rpt_level==3
  76.       save_3sn=save_3sn+1
  77.          if exists("asm_mbr_tuhao") /*检查“tuhao”参数
  78.             ctuhao=asm_mbr_tuhao /*将第三层的图号提取到"ctuhao"中
  79.          else
  80.             ctuhao="父项无图号"
  81.          endif
  82.       futuhao=btuhao /*第三层的父图号等于第二层的图号
  83.       if current_level<rpt_level
  84.          save_3sn=1
  85.       endif
  86.       /*save_4sn=save_3sn   
  87.    endif
  88.    if rpt_level==4
  89.       save_4sn=save_4sn+1
  90.          if exists("asm_mbr_tuhao") /*检查“tuhao”参数
  91.             dtuhao=asm_mbr_tuhao /*将第4层的图号提取到"dtuhao"中
  92.          else
  93.             dtuhao="父项无图号"
  94.          endif
  95.       futuhao=ctuhao /*第4层的父图号等于第3层的图号
  96.       if current_level<rpt_level
  97.          save_4sn=1
  98.       endif
  99.    endif
  100.    if rpt_level==5
  101.       save_5sn=save_5sn+1
  102.          if exists("asm_mbr_tuhao") /*检查“tuhao”参数
  103.             etuhao=asm_mbr_tuhao /*将第5层的图号提取到"etuhao"中
  104.          else
  105.             etuhao="父项无图号"
  106.          endif
  107.       futuhao=dtuhao /*第5层的父图号等于第4层的图号
  108.       if current_level<rpt_level
  109.          save_5sn=1
  110.       endif
  111.    endif
  112.    /*加入点
  113.    current_level=rpt_level
  114. endif


  115. if rpt_level==2
  116.    myidx=itos(save_2sn)
  117. endif
  118. if rpt_level==3
  119.    myidx=itos(save_2sn)+"."+itos(save_3sn)
  120. endif
  121. if rpt_level==4
  122.    myidx=itos(save_2sn)+"."+itos(save_3sn)+"."+itos(save_4sn)
  123. endif
  124. if rpt_level==5
  125.    myidx=itos(save_2sn)+"."+itos(save_3sn)+"."+itos(save_4sn)+"."+itos(save_5sn)
  126. endif
  127. /*加入点
  128. endif

  129. /*显示物料
  130. if exists("asm_mbr_erpfl")==FALSE /*检查自定义“ERPFL”参数
  131. wuliao = asm_mbr_tuhao /*没有,则图号就是物料号,公司将自制件的图号当作物料号,所以自制件不设“ERPFL”参数
  132. else
  133. if asm_mbr_mcwl==" "||asm_mbr_mcwl=="" /*当自定义“mcwl”参数值为空或只有一个空格时
  134. wuliao = "没有物料号"  /*提示没有物料号
  135. else
  136. wuliao = asm_mbr_mcwl  /*有就显示物料号
  137. endif
  138. endif
复制代码
以上是我修改别人的代码,由于我不会编程,所以肯定有很多遗漏或错误的地方,在此只是抛砖引玉,还希望各位能多多指正。
同时也希望能帮助到更多的人。
运行后的:



版权声明  
本人声明此帖为本人原创帖,未经允许,不得转载!

有奖推广贴子: 

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

 
 
QQ:1359218528
工作时间:
9:00-17:00
 
微信公众号
手机APP
机械社区
微信小程序

手机版|UG爱好者论坛 ( 京ICP备10217105号-2 )    论坛管理员QQ:1359218528

本站信息均由会员发表,不代表本网站立场,如侵犯了您的权利请联系管理员,邮箱:1359218528@qq.com  

Powered by UG爱好者 X3.2  © 2001-2014 Comsenz Inc. GMT+8, 2024-6-18 00:51

返回顶部