CATIA VBA EBom应用

原文链接

1.将工程图零件序号创建更改/设置为零件号。

Tools - Options -> Drafting -> Balloon Creation,此选项将自动生成部件中零件编号的零件序号。

2.在零件属性中更改/设置零件号为您需要生成在BOM表中的编号。
3.选择需要输出BOM的装配,启动程序。

e3bomV1.catvbs代码参考如下:

' bom, (c)ema, lm:13.7.2009
'
Language="VBSCRIPT"
Sub CATMain()
' ******************************* test if product is open *****************************
  If CATIA.Documents.Count = 0 Then
    MsgBox "There is no CATIA Documents open. Open a Product file and run this script again.", ,msgboxtext
    Exit Sub
  End If
  If InStr(CATIA.ActiveDocument.Name, ".CATProduct") < 1 Then
    MsgBox "Active CATIA Document is not a Product. Open a Product file and run this script again.", ,msgboxtext
    Exit Sub
  End If
' ******************************* variables *******************************************
  Set cad = CATIA.ActiveDocument
  Set sel = cad.selection
  set prod=cad.Product.Products
  msgboxtext="e3bom - Bill of Material"
  dim tab(4,1999)
  k=0
' ******************************* test if some parts is selected **********************
  If sel.count =0 Then
    MsgBox "No any parts for BOM is selected. Select some parts and run this script again.", ,msgboxtext
    Exit Sub
  End If
  If sel.count >=1999 Then
    MsgBox "Number of selected parts for BOM exceeds 1999. Program error.", ,msgboxtext
    Exit Sub
  End If
' ******************************* load ************************************************
  for i=1 to prod.count
    for j=1 to sel.count
      if prod.item(i).name=sel.item(j).reference.name then
        k=k+1
        tab(1,k)=prod.item(i).PartNumber
        tab(2,k)=sel.item(j).reference.name
        tab(3,k)=prod.item(i).DescriptionRef
        tab(4,k)=1
      end if
    next
  next
' ******************************* sort ************************************************
  if k>1 then
    for i=1 to k-1 
      for j=i+1 to k
        if tab(1,i)>tab(1,j)then
          tab(1,1999)=tab(1,j)
          tab(2,1999)=tab(2,j)
          tab(3,1999)=tab(3,j)
          tab(4,1999)=tab(4,j)
          tab(1,j)=tab(1,i)
          tab(2,j)=tab(2,i)
          tab(3,j)=tab(3,i)
          tab(4,j)=tab(4,i)
          tab(1,i)=tab(1,1999)
          tab(2,i)=tab(2,1999)
          tab(3,i)=tab(3,1999)
          tab(4,i)=tab(4,1999)
        end if
      next
    next
' ******************************* count ***********************************************
    for i=1 to k-1
      for j=i+1 to k
        if tab(1,i)=tab(1,j) and j<=k then
          
                
            
QR Code
微信扫一扫,欢迎咨询~

联系我们
武汉格发信息技术有限公司
湖北省武汉市经开区科技园西路6号103孵化器
电话:155-2731-8020 座机:027-59821821
邮件:tanzw@gofarlic.com
Copyright © 2023 Gofarsoft Co.,Ltd. 保留所有权利
遇到许可问题?该如何解决!?
评估许可证实际采购量? 
不清楚软件许可证使用数据? 
收到软件厂商律师函!?  
想要少购买点许可证,节省费用? 
收到软件厂商侵权通告!?  
有正版license,但许可证不够用,需要新购? 
联系方式 155-2731-8020
预留信息,一起解决您的问题
* 姓名:
* 手机:

* 公司名称:

姓名不为空

手机不正确

公司不为空