Macro to change the Part Number of every Part in a Product
Macro to change the Part Number of every Part in a Product
(OP)
Hello everyone.
I need to change the PartName and the Instance name of every Part to any number i want, but only the first seven digits should change. I have a macro with wich i can change the Instance name but nothing that can rename the Partname with the Instance name.
The Product has several Parts. They have the following naming structure:
xxxxxxx_A_1_A_ProductName
xxxxxxx_0001_PartName1 (xxxxxxx_0001_PartName1)
xxxxxxx_0002_Partname2 (xxxxxxx_0002_PartName2)
....
I used the recording tool to create a macro and renamed the Part Number of the first Part.
The next step should be a loop, so that the seven digits of the other Parts would change as well. Unfortunately i dont know how to write this loop.
Language="VBSCRIPT"
Sub CATMain()
Dim documents1 As Documents
Set documents1 = CATIA.Documents
Dim partDocument1 As Document
Set partDocument1 = documents1.Item("0000001__0001__Untere_Platte.CATPart")
Dim product1 As CATBaseDispatch
Set product1 = partDocument1.GetItem("0000001__0001__Untere_Platte")
product1.PartNumber = "0000002__0001__Untere_Platte"
End Sub
Is there anything one could do to help me?
Thanks, Rob
I need to change the PartName and the Instance name of every Part to any number i want, but only the first seven digits should change. I have a macro with wich i can change the Instance name but nothing that can rename the Partname with the Instance name.
The Product has several Parts. They have the following naming structure:
xxxxxxx_A_1_A_ProductName
xxxxxxx_0001_PartName1 (xxxxxxx_0001_PartName1)
xxxxxxx_0002_Partname2 (xxxxxxx_0002_PartName2)
....
I used the recording tool to create a macro and renamed the Part Number of the first Part.
The next step should be a loop, so that the seven digits of the other Parts would change as well. Unfortunately i dont know how to write this loop.
Language="VBSCRIPT"
Sub CATMain()
Dim documents1 As Documents
Set documents1 = CATIA.Documents
Dim partDocument1 As Document
Set partDocument1 = documents1.Item("0000001__0001__Untere_Platte.CATPart")
Dim product1 As CATBaseDispatch
Set product1 = partDocument1.GetItem("0000001__0001__Untere_Platte")
product1.PartNumber = "0000002__0001__Untere_Platte"
End Sub
Is there anything one could do to help me?
Thanks, Rob





RE: Macro to change the Part Number of every Part in a Product
http://www.learn.net.au/vba/vba-loops
indocti discant et ament meminisse periti
RE: Macro to change the Part Number of every Part in a Product
??????........
Try not to expect complete solution to your problem.
We want you to solve this by becoming one of the programmer....
Go to FAQs page you will find links to some materials to go through.
Regards,
Maddy