Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations KootK on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Custom BOM in Portable script center

Status
Not open for further replies.

reutov_tv

Industrial
Jan 16, 2024
33
I tried to create a BOM using the scripts from PortableScriptCenter v2, but I was not successful. Could someone please help me with this issue? There is two version of custom BOM macro, could you tell me which one works well?
I would like to customize and save BOM structure for reuse in drafting module.

Thank you
 
Replies continue below

Recommended for you

would be easier for us if you post the code you use and describe the error message you have

Eric N.
indocti discant et ament meminisse periti
 
itsmyjob

I'm not quite sure what these scripts do.
My goal is to save the BOM settings so that for new assemblies I can get a table like this (column names may vary):
Number | Part Number | Nomenclature | Qty
No need for recapitulation. Only top-level components. Perhaps I am wrong but these scripts generate Excel table only. Is it possible to generate associative tables as in built-in Catia command Generate-BOM/Advanced BOM?

BOM_in_EXCEL

Language="VBSCRIPT"

Sub CATMain()

Dim productDocument1 As Document
Set productDocument1 = CATIA.ActiveDocument

Dim product1 As Product
Set product1 = productDocument1.Product

Dim assemblyConvertor1 As CATBaseDispatch
Set assemblyConvertor1 = product1.GetItem("BillOfMaterial")

Dim arrayOfVariantOfBSTR1(7) 'change number if you have more custom columns/array...
arrayOfVariantOfBSTR1(0) = "Quantity"
arrayOfVariantOfBSTR1(1) = "Part Number"
arrayOfVariantOfBSTR1(2) = "Type"
arrayOfVariantOfBSTR1(3) = "Nomenclature"
arrayOfVariantOfBSTR1(4) = "Revision"
arrayOfVariantOfBSTR1(5) = "Mass" 'in addition of what is by default
arrayOfVariantOfBSTR1(6) = "Density" 'in addition of what is by default
arrayOfVariantOfBSTR1(7) = "Material" 'in addition of what is by default

assemblyConvertor1.SetCurrentFormat arrayOfVariantOfBSTR1

Dim arrayOfVariantOfBSTR2(1) 'change number if you have more custom columns/array...
arrayOfVariantOfBSTR2(0) = "Quantity"
arrayOfVariantOfBSTR2(1) = "Part Number"

assemblyConvertor1.SetSecondaryFormat arrayOfVariantOfBSTR2

assemblyConvertor1.Print "TXT", "c:\temp\Custom_BOM.txt", product1



Set xlApp = CreateObject("Excel.Application")

Set MyXL = GetObject(, "Excel.Application")

If Err.Number <> 0 Then ExcelWasNotRunning = True

Err.Clear

Set MyXL = GetObject("C:\temp\Book1.xls")

MyXL.Application.Visible = True

MyXL.Parent.Windows(1).Visible = True



End Sub


BOM_in_Excel_similar_code

Language="VBSCRIPT"



Sub CATMain()



Msgbox "You need an excel file named Ready_for_BOM_in_EXCEL.xls in c:\temp\ folder with a code inside - see page "



Dim productDocument1 As Document

Set productDocument1 = CATIA.ActiveDocument



Dim product1 As Product

Set product1 = productDocument1.Product



Dim assemblyConvertor1 As CATBaseDispatch

Set assemblyConvertor1 = product1.GetItem("BillOfMaterial")



Dim arrayOfVariantOfBSTR1(7) 'change number if you have more custom columns/array...

arrayOfVariantOfBSTR1(0) = "Quantity"

arrayOfVariantOfBSTR1(1) = "Part Number"

arrayOfVariantOfBSTR1(2) = "Type"

arrayOfVariantOfBSTR1(3) = "Nomenclature"

arrayOfVariantOfBSTR1(4) = "Revision"

arrayOfVariantOfBSTR1(5) = "Mass" 'in addition of what is by default

arrayOfVariantOfBSTR1(6) = "Density" 'in addition of what is by default

arrayOfVariantOfBSTR1(7) = "Material" 'in addition of what is by default



assemblyConvertor1.SetCurrentFormat arrayOfVariantOfBSTR1



Dim arrayOfVariantOfBSTR2(1) 'change number if you have more custom columns/array...

arrayOfVariantOfBSTR2(0) = "Quantity"

arrayOfVariantOfBSTR2(1) = "Part Number"



assemblyConvertor1.SetSecondaryFormat arrayOfVariantOfBSTR2



assemblyConvertor1.Print "TXT", "c:\temp\Custom_BOM.txt", product1







Set xlApp = CreateObject("Excel.Application")



Set MyXL = GetObject(, "Excel.Application")



If Err.Number <> 0 Then ExcelWasNotRunning = True



Err.Clear



Set MyXL = GetObject("C:\temp\Ready_for_BOM_in_EXCEL.xls")



MyXL.Application.Visible = True



MyXL.Parent.Windows(1).Visible = True



Msgbox "BOM saved in c:\temp\Custom_BOM.xls file "



End Sub


Custom_BOM

Language="VBSCRIPT"



Sub CATMain()



Dim productDocument1 As Document

Set productDocument1 = CATIA.ActiveDocument



Dim product1 As Product

Set product1 = productDocument1.Product



Dim assemblyConvertor1 As CATBaseDispatch

Set assemblyConvertor1 = product1.GetItem("BillOfMaterial")



Dim arrayOfVariantOfBSTR1(7) 'change number if you have more custom columns/array...

arrayOfVariantOfBSTR1(0) = "Quantity"

arrayOfVariantOfBSTR1(1) = "Part Number"

arrayOfVariantOfBSTR1(2) = "Type"

arrayOfVariantOfBSTR1(3) = "Nomenclature"

arrayOfVariantOfBSTR1(4) = "Revision"

arrayOfVariantOfBSTR1(5) = "Mass" 'in addition of what is by default

arrayOfVariantOfBSTR1(6) = "Density" 'in addition of what is by default

arrayOfVariantOfBSTR1(7) = "Material" 'in addition of what is by default



assemblyConvertor1.SetCurrentFormat arrayOfVariantOfBSTR1



Dim arrayOfVariantOfBSTR2(1) 'change number if you have more custom columns/array...

arrayOfVariantOfBSTR2(0) = "Quantity"

arrayOfVariantOfBSTR2(1) = "Part Number"



assemblyConvertor1.SetSecondaryFormat arrayOfVariantOfBSTR2



assemblyConvertor1.Print "TXT", "c:\temp\Custom_BOM.txt", product1



End Sub


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor