-
1
- #1
Hi Friends,
I have created this macro to rename all parts ( unique parts) in a product.
Also it will 'save as' the new parts with the new name.
Comments are welcome
Thanks
Vikt
*********************************************************
Option Explicit
Sub CATMain()
Dim iCount As Integer
Dim sSuffix As String
Dim sNewName As String
sSuffix = "_00"
'To avoid save as warnings*********
CATIA.DisplayFileAlerts = False
Dim productDocument1 As ProductDocument
Set productDocument1 = CATIA.ActiveDocument
Dim product1 As Product
Set product1 = productDocument1.Product
Dim products1 As Products
Set products1 = product1.Products
For iCount = 1 To products1.Count
products1.Item(iCount).PartNumber = products1.Item(iCount).PartNumber & sSuffix
sNewName = products1.Item(iCount).PartNumber
Dim documents1 As Documents
Set documents1 = CATIA.Documents
iCount = iCount + 1
Dim doc1 As Document
Set doc1 = documents1.Item(iCount)
doc1.SaveAs "C:\FolderLocationWhereYouWantToSaveParts\" & sNewName & ".CATPart"
iCount = iCount - 1
Next iCount
End Sub
I have created this macro to rename all parts ( unique parts) in a product.
Also it will 'save as' the new parts with the new name.
Comments are welcome
Thanks
Vikt
*********************************************************
Option Explicit
Sub CATMain()
Dim iCount As Integer
Dim sSuffix As String
Dim sNewName As String
sSuffix = "_00"
'To avoid save as warnings*********
CATIA.DisplayFileAlerts = False
Dim productDocument1 As ProductDocument
Set productDocument1 = CATIA.ActiveDocument
Dim product1 As Product
Set product1 = productDocument1.Product
Dim products1 As Products
Set products1 = product1.Products
For iCount = 1 To products1.Count
products1.Item(iCount).PartNumber = products1.Item(iCount).PartNumber & sSuffix
sNewName = products1.Item(iCount).PartNumber
Dim documents1 As Documents
Set documents1 = CATIA.Documents
iCount = iCount + 1
Dim doc1 As Document
Set doc1 = documents1.Item(iCount)
doc1.SaveAs "C:\FolderLocationWhereYouWantToSaveParts\" & sNewName & ".CATPart"
iCount = iCount - 1
Next iCount
End Sub