×
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

Macro to rename and save all unique parts in a product

Macro to rename and save all unique parts in a product

Macro to rename and save all unique parts in a product

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

RE: Macro to rename and save all unique parts in a product

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

https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...

RE: Macro to rename and save all unique parts in a product

(OP)
Thanks for the comments ferdo...
That was helpful.

vikt

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! Already a Member? Login


Resources

White Paper - PLM and ERP: Their Respective Roles in Modern Manufacturing
Leading manufacturers are aligning their people, processes, and tools from initial product ideation through to field service. They do so by providing access to product and enterprise data in the context of each person’s domain expertise. However, it can be complicated and costly to unite engineering with the factory and supply chain. Download Now

Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close