Macro to change partname and instance name
Macro to change partname and instance name
(OP)
Hi Friends,
I have written a code for renaming all part's name and instance inside a product.
For eg. if it is part1(part1.1), part2(part2.2)
it will change the number and instance to say vik1(vik1.1),vik2(vik2.2)
I have just started with automation, need suggestion, wht other things i can add or change to make it better.
PFB the code.
*************************
Sub CATMain()
Dim iCount As Integer
Dim sPoint As String
sPoint = "."
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 = "vikas" & iCount
products1.Item(iCount).Name = products1.Item(iCount).PartNumber & sPoint & iCount
Next iCount
End Sub
****************************************************************************
All suggestion and comments are welcome.
Thanks.
I have written a code for renaming all part's name and instance inside a product.
For eg. if it is part1(part1.1), part2(part2.2)
it will change the number and instance to say vik1(vik1.1),vik2(vik2.2)
I have just started with automation, need suggestion, wht other things i can add or change to make it better.
PFB the code.
*************************
Sub CATMain()
Dim iCount As Integer
Dim sPoint As String
sPoint = "."
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 = "vikas" & iCount
products1.Item(iCount).Name = products1.Item(iCount).PartNumber & sPoint & iCount
Next iCount
End Sub
****************************************************************************
All suggestion and comments are welcome.
Thanks.





RE: Macro to change partname and instance name
Also You should consider to rename only documents that are Parts, not Products (then You need to create other variable for instance number)
LukaszSz. Poland, Warsaw University of Technology, Faculty of Power and Aeronautical Engineering : MEchanical Engineering. BsC - 2013
RE: Macro to change partname and instance name
In some companies you need to have same name in Part Number and Instance Name doesn't matter if is Part, Product or Component. They can be also different, specific ones, according to some rules specified in different procedures.
Lukaszsz is right, search the forum for more infos.
Regards
Fernando
https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...