Unique part counting macro
Unique part counting macro
(OP)

Hi gays!
I have Question.
this picture One Product and sub part exist.
i wanna counting catpart.

this picture is Bom
i wanna msgbox show redbox contents.
below my script help me.
Public uPartCounter As Integer
Public prodArray() As String
Public compArray() As String
Public ProdName, compName As String
Public partcounter As Long
Sub
CATMain()
upartcounter = 0
Dim oMyProduct As Product
Set oMyProduct = CATIA.ActiveDocument.Product
upartcounter = oMyProduct.PartNumber
Dim iLevel As Integer
iLevel = -1
partCounter = 1
Dim x, m As Integer
m = UBound(prodArray)
For x = 1 To m
ProdName = prodArray(x)
compName = compArray(x)
partcounter = partcounter + 1
mgsbox “The total number of unique parts is: ” & upartcounter
end sub





RE: Unique part counting macro
Regards,
Maddy
The willingness to share knowledge does not make one charitable; it makes one self-reliant to know more.
Modified - Courtesy of Robert Brault
RE: Unique part counting macro
Link
Link
RE: Unique part counting macro
I want to see by the number of parts of the same thing that comes to msgbox window with the following code.
msgbox
For example, Part1: 3ea
Part2: 2ea
below attached code it made by 'lukaszsz'
Dim Listed
Sub CATMain()
Set productDocument1 = CATIA.ActiveDocument
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
ProductName=""
Call ListingNames(productDocument1.Product,ProductName)
Msgbox Listed
End Sub
Sub ListingNames(current_prod,pathname)
If current_prod.Products.Count > 0 Then
pathname2 = pathname &"\"& current_prod.name
For i = 1 To current_prod.Products.Count
Call ListingNames(current_prod.Products.Item(i),pathname2)
Next
Else
'MsgBox pathname &"\" & current_prod.Name
Listed = Listed & chr(10) & pathname &"\" & current_prod.Name
End If
End Sub