PavelsBabbles
Aerospace
- Oct 28, 2015
- 3
I need some help with this macro (I found this from a different thread on here). The objective with this macro is to rename all parts/assemblies in catia to their respective file names. I can not get this code to run properly. Does anyone have an alternative macro, or see what is wrong with this one?
Code:
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
Call ListingNames(productDocument1.Product)
End Sub
Sub ListingNames(current_prod)
If current_prod.Products.Count > 0 Then
For i = 1 To current_prod.Products.Count
Call ListingNames(current_prod.Products.Item(i))
If InStr(current_prod.Products.Item(i).ReferenceProduct.Parent.Name, ".CATProduct") > 0 Then
current_prod.Products.Item(i).PartNumber = Left(current_prod.Products.Item(i).ReferenceProduct.Parent.Name, Len(current_prod.Products.Item(i).ReferenceProduct.Parent.Name) - 11)
End If
Next
Else
If InStr(current_prod.ReferenceProduct.Parent.Name, ".CATPart") > 0 Then
current_prod.PartNumber = Left(current_prod.ReferenceProduct.Parent.Name, Len(current_prod.ReferenceProduct.Parent.Name) - 8)
End If
End If
End Sub