Continue to Site

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!

Unique part counting macro

Status
Not open for further replies.

seojinuk

Mechanical
May 15, 2013
3
KR
ex.png


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

ex2.png


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
 
Replies continue below

Recommended for you

where is the pictures??



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
 
I found the code so that it was similar to just started in the forum.

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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Top