×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Unique part counting macro

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

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

RE: Unique part counting macro

(OP)
so sorry below i attached img link

Link

Link

RE: Unique part counting macro

(OP)
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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources