×
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

Jobs

Instance Renaming Macro

Instance Renaming Macro

Instance Renaming Macro

(OP)
I've searched the forums for macros that will rename instances within a CATProduct, but haven't had much luck in finding one that I think fits the bill for me.

What I want to do, is rename only the instances of the CATParts within a CATProduct.

{Tree}
Assembly.Catproduct
--ItemA (SHCS.45)
--ItemA (SHCS.47)
--ItemA (SHCS.78)
.
.
.
--ItemB (WASHER.54)
--ItemB (WASHER.22)
--ItemB (WASHER.63)
.
.
.
.
--ItemC (NUT.55)
--ItemC (NUT.62)
--ItemC (NUT.87)

What I want to do, is leave the part names alone and only renumber the instances. I want to change SHCS.45 to SHCS.1, SHCS.47 to SHCS.2, WASHER.54 to WASHER.1, WASHER.22 to WASHER.2, etc. etc.

I know there has to be a macro out there that will accomplish this, but I haven't had any luck in searching for one.

Any help will be appreciated.

Renaming the instances of 100+ washers isn't fun. tongue

RE: Instance Renaming Macro

CODE -->

Sub Rename_Products()

Dim x, y, z As Integer
x = 1
y = 1
z = 1
Dim objRootProductDoc As ProductDocument
Set objRootProductDoc = CATIA.ActiveDocument

Dim objProduct1 As Product
Set objProduct1 = objRootProductDoc.GetItem("Assembly")

Set objProduct1 = objProduct1.Products
For i = 1 To objProduct1.Products.Count
Set objProduct2 = objProduct1.Products.Item(i)


Select Case objProduct2.PartNumber

Case "ItemA"

objProduct2.Name = "SHCS." & x
x = x + 1
Case "ItemB"
objProduct2.Name = "WASHER." & y
y = y + 1
Case "ItemC"
objProduct2.Name = "NUT." & z
z = z + 1

End Select

Next i


End Sub 

something to start..

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!


Resources