Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

CATPart from Product name

hadzi11

Mechanical
Feb 6, 2025
4
Hello,

I need to create CATPart from Product but I need the original part names to be the new body names. The tree looks something like this now.
1740402550681.png
So I would need it to be just one single part (25F6003) and the bodies inside should be named after the current part names (25F6626 etc.) - each part currently contains one body.

Is there any way to do this?

Thanks for any help in advance.
 
Replies continue below

Recommended for you

this functionality exists in Assembly Design Workbench (Tools-Generate CATPart from Product) or in Infrastructure/Product Data Filtering (Product To Part)
 
I understand the feature exists, but I need the bodies in the CATPart that come from a Product to be named after their respective part names (for example, 25F6626). Currently, the export uses the body names instead of the part names. In other words, I need the body to inherit the name of its corresponding CATPart.
1740404834539.png
So after export the body that would come from 25F6626 part would be named 25F6626 (NAUO260)
1740404919202.png
 
Hello,

I came to a solution using macro in case somebody bumps into similiar issue. I had to do 40 assemblies and each contains around 100 parts so doing it manually is really not an option. Here is the macro - after creating CATPart from Product manually you have to set the first body as main body and delete the empty one that appears so the order and quantity of bodies are equal to the original order of parts in assembly - then run the macro and it renames all bodies after part number of original parts.

Sub CATMain()
Dim CATIAApp, Assembly, NewPartDoc, NewPart
Dim i, partNumber, bodyCount, activePartName, targetAssemblyName

Set CATIAApp = CATIA

If CATIAApp.ActiveDocument Is Nothing Then
MsgBox "Žiadny aktívny dokument."
Exit Sub
End If

activePartName = CATIAApp.ActiveDocument.Name

If InStr(activePartName, "_AllCATPart.CATPart") > 0 Then
targetAssemblyName = Replace(activePartName, "_AllCATPart.CATPart", "") & ".CATProduct"
Else
targetAssemblyName = activePartName & ".CATProduct"
End If

On Error Resume Next
Set Assembly = CATIAApp.Documents.Item(targetAssemblyName).Product
On Error GoTo 0
If Assembly Is Nothing Then
MsgBox "Nebola nájdená zostava: " & targetAssemblyName & ". Uistite sa, že máte otvorenú zostavu."
Exit Sub
End If

Set NewPartDoc = CATIAApp.ActiveDocument
If TypeName(NewPartDoc) <> "PartDocument" Then
MsgBox "Aktívny dokument nie je Part dokument. Skontrolujte, či ste potvrdili dialóg."
Exit Sub
End If

Set NewPart = NewPartDoc.Part
bodyCount = NewPart.Bodies.Count

If bodyCount <> Assembly.Products.Count Then
MsgBox "Upozornenie: Počet tiel (" & bodyCount & ") sa nezhoduje s počtom komponentov (" & Assembly.Products.Count & ")."
End If

For i = 1 To Assembly.Products.Count
partNumber = Assembly.Products.Item(i).PartNumber
If partNumber = "" Then
partNumber = Assembly.Products.Item(i).Name
End If
NewPart.Bodies.Item(i).Name = partNumber
Next

NewPart.Update
MsgBox "Telá boli premenované podľa Part Number."
End Sub
 

Part and Inventory Search

Sponsor