JCReynolds79
Automotive
- Sep 6, 2007
- 115
Hi Folks,
I am pulling my hair out a bit. I want to extract a BOM for a product in a lower portion of the main Product. i.e. a sub-assembly.
Product Tree e.g.:
Product (this is the Window's top level product)
-> Product 1
- -> Product 2
- - -> Product 3
- - - -> Product 4
I created a macro by "recording" the following actions...
1. Double Click on "Product 4" to activate it.
2. Go to Analyze -> Bill of Material... -> Save As... (save somewhere locally).
3. Stop recording.
The created macro looks like this:
This works fine...BUT as a useful macro, the names of the products are all hard-coded...I want to be able to run this macro, either with the sub-assy already "double-clicked" or prompt user to select in tree and extract its BOM.
The bit I am struggling with is GetItem of the desired sub-assy. I can get a BOM of the very top level easy enough, but cannot figure out how to JUST get the selected lower level sub-assy.
Hope someone can help.
Many thanks.
Regards,
Jon Reynolds
I am pulling my hair out a bit. I want to extract a BOM for a product in a lower portion of the main Product. i.e. a sub-assembly.
Product Tree e.g.:
Product (this is the Window's top level product)
-> Product 1
- -> Product 2
- - -> Product 3
- - - -> Product 4
I created a macro by "recording" the following actions...
1. Double Click on "Product 4" to activate it.
2. Go to Analyze -> Bill of Material... -> Save As... (save somewhere locally).
3. Stop recording.
The created macro looks like this:
Code:
Language="VBSCRIPT"
Sub CATMain()
Set productDocument1 = CATIA.ActiveDocument
Set product1 = productDocument1.Product
Set products1 = product1.Products
Set product2 = products1.Item("Product 1.1")
Set products2 = product2.Products
Set product3 = products2.Item("Product 2.1")
Set products3 = product3.Products
Set product4 = products3.Item("Product 3.1")
Set products4 = product4.Products
Set product5 = products4.Item("Product 4.2")
Set assemblyConvertor1 = product5.GetItem("BillOfMaterial")
Dim arrayOfVariantOfBSTR1(2)
arrayOfVariantOfBSTR1(0) = "Part Number"
arrayOfVariantOfBSTR1(1) = "Revision"
arrayOfVariantOfBSTR1(2) = "Description"
assemblyConvertor1.SetCurrentFormat arrayOfVariantOfBSTR1
assemblyConvertor1.Print "TXT", "C:\Users\me\macros\bom.txt", product5
End Sub
This works fine...BUT as a useful macro, the names of the products are all hard-coded...I want to be able to run this macro, either with the sub-assy already "double-clicked" or prompt user to select in tree and extract its BOM.
The bit I am struggling with is GetItem of the desired sub-assy. I can get a BOM of the very top level easy enough, but cannot figure out how to JUST get the selected lower level sub-assy.
Hope someone can help.
Many thanks.
Regards,
Jon Reynolds