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!

Instance Renaming Macro

Status
Not open for further replies.

djmjr

Aerospace
Feb 7, 2014
22
US
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]
 
Replies continue below

Recommended for you

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..
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Top