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!

Macro to rename and save all unique parts in a product 1

Status
Not open for further replies.

vikt

Mechanical
Mar 13, 2013
52
US
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
 
Hi,

Nice, maybe some improvements ? [wink]

- Do the change for multilevel products
- InputBox for path where to save
- InputBox for suffix or prefix (if implemented)
- Save also the CATProducts
- Change the name also for components, not only CATParts (or CATProducts) - I believe now is done for first level



Regards
Fernando

 
Thanks for the comments ferdo...
That was helpful.

vikt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Top