Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

thread560-238442 I have used the 1

Status
Not open for further replies.

vjxzy

Automotive
Jan 31, 2019
13
IN
thread560-238442

I have used the code in the above thread but the part number showing in the txt file is only 20 space. Is there any other additional code to get full name of the part
Capture_pwckle.jpg
 
Replies continue below

Recommended for you

Hello,
I am not sure if you can modify your code to show more characters. In "AssemblyConvertor" class I do not see any options on how to set that.

But, you can try something like below:

Code:
Option Explicit

Sub Main()
    Dim CATIA
    Dim doc, prod
    
    Set CATIA = GetObject(, "CATIA.Application")
    Set doc = CATIA.ActiveDocument
    Set prod = CATIA.ActiveDocument.Product
    
    Dim dict
    Set dict = GetProductBOM(doc, prod)
    
    Dim k As Variant
    For Each k In dict.Keys
        Debug.Print k, dict(k)
    Next
End Sub

Function GetProductBOM(doc, prod)
    Dim dict
    Dim curr As Product
    Dim dictKey As String
    
    Set dict = CreateObject("Scripting.Dictionary")
    
    For Each curr In prod.Products
        Do
            dictKey = curr.PartNumber
            
            If dict.Exists(dictKey) Then
                dict(dictKey) = dict(dictKey) + 1
            Else
                dict.Add dictKey, 1
            End If
        Loop While False
    Next
    
    Set GetProductBOM = dict
End Function

It prints into a debug window a BOM: Part Number, Quantity for the first level of the active product. If you would like to include also deeper levels, you have to use recursion.


Tesak
- Text along a curve for Catia V5
 
Thank you for your reply i'm not getting it exactly ill turn to figure it out.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top