kylincy* 发表于 2016-4-25 18:19:34

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

本帖最后由 kylincy 于 2016-4-25 18:33 编辑

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

if rpt_index>save_idx
   save_idx=rpt_index
   pass_num=0
else
   pass_num=save_idx
endif

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

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

if current_level==rpt_level
    if rpt_level==2
         if exists("asm_mbr_tuhao") /*检查“tuhao”参数
            btuhao=asm_mbr_tuhao /*将第二层的图号提取到"btuhao"中
         else
            btuhao="父项无图号"
         endif
      futuhao=atuhao /*第二层的父图号等于第一层的图号
      save_2sn=save_2sn+1
   endif
   if rpt_level==3
         if exists("asm_mbr_tuhao") /*检查“tuhao”参数
            ctuhao=asm_mbr_tuhao /*将第三层的图号提取到"ctuhao"中
         else
            ctuhao="父项无图号"
         endif
      futuhao=btuhao /*第三层的父图号等于第二层的图号
      save_3sn=save_3sn+1
   endif
   if rpt_level==4
         if exists("asm_mbr_tuhao") /*检查“tuhao”参数
            dtuhao=asm_mbr_tuhao /*将第4层的图号提取到"dtuhao"中
         else
            dtuhao="父项无图号"
         endif
      futuhao=ctuhao /*第4层的父图号等于第3层的图号
      save_4sn=save_4sn+1
   endif
   if rpt_level==5
         if exists("asm_mbr_tuhao") /*检查“tuhao”参数
            etuhao=asm_mbr_tuhao /*将第5层的图号提取到"etuhao"中
         else
            etuhao="父项无图号"
         endif
      futuhao=dtuhao /*第5层的父图号等于第4层的图号
      save_5sn=save_5sn+1
   endif
   /*加入点
else      
   if rpt_level==2
      save_2sn=save_2sn+1
      /*save_4sn=save_2sn
         if exists("asm_mbr_tuhao") /*检查“tuhao”参数
            btuhao=asm_mbr_tuhao /*将第二层的图号提取到"btuhao"中
         else
            btuhao="父项无图号"
         endif
      futuhao=atuhao /*第二层的父图号等于第一层的图号
   endif
   if rpt_level==3
      save_3sn=save_3sn+1
         if exists("asm_mbr_tuhao") /*检查“tuhao”参数
            ctuhao=asm_mbr_tuhao /*将第三层的图号提取到"ctuhao"中
         else
            ctuhao="父项无图号"
         endif
      futuhao=btuhao /*第三层的父图号等于第二层的图号
      if current_level<rpt_level
         save_3sn=1
      endif
      /*save_4sn=save_3sn   
   endif
   if rpt_level==4
      save_4sn=save_4sn+1
         if exists("asm_mbr_tuhao") /*检查“tuhao”参数
            dtuhao=asm_mbr_tuhao /*将第4层的图号提取到"dtuhao"中
         else
            dtuhao="父项无图号"
         endif
      futuhao=ctuhao /*第4层的父图号等于第3层的图号
      if current_level<rpt_level
         save_4sn=1
      endif
   endif
   if rpt_level==5
      save_5sn=save_5sn+1
         if exists("asm_mbr_tuhao") /*检查“tuhao”参数
            etuhao=asm_mbr_tuhao /*将第5层的图号提取到"etuhao"中
         else
            etuhao="父项无图号"
         endif
      futuhao=dtuhao /*第5层的父图号等于第4层的图号
      if current_level<rpt_level
         save_5sn=1
      endif
   endif
   /*加入点
   current_level=rpt_level
endif


if rpt_level==2
   myidx=itos(save_2sn)
endif
if rpt_level==3
   myidx=itos(save_2sn)+"."+itos(save_3sn)
endif
if rpt_level==4
   myidx=itos(save_2sn)+"."+itos(save_3sn)+"."+itos(save_4sn)
endif
if rpt_level==5
   myidx=itos(save_2sn)+"."+itos(save_3sn)+"."+itos(save_4sn)+"."+itos(save_5sn)
endif
/*加入点
endif

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



页: [1]
查看完整版本: 多级序号与所属装配显示;物料号的显示。