Part to Product Macro Issue
Part to Product Macro Issue
(OP)
I currently have a CATScript Macro that creates a Product from a Catia Part with multiple bodies.
When i run this macro, and it runs into a body that has a name that already exists it throws a pup up box stating:
The item xxxx already exists.
Do you want it to be overwritten?
I have a bunch of parts that have hundreds of bodies like this.
Is there a macro that renames duplicate part bodies?
All I need the macro to do is add a -1, -2, or -3 on duplicate part bodies before i run the Part to Product macro.
Example: Starting Name: XXX, Duplicate Names: XXX-1, XXX-2, and XXX-3.
When i run this macro, and it runs into a body that has a name that already exists it throws a pup up box stating:
The item xxxx already exists.
Do you want it to be overwritten?
I have a bunch of parts that have hundreds of bodies like this.
Is there a macro that renames duplicate part bodies?
All I need the macro to do is add a -1, -2, or -3 on duplicate part bodies before i run the Part to Product macro.
Example: Starting Name: XXX, Duplicate Names: XXX-1, XXX-2, and XXX-3.





RE: Part to Product Macro Issue
BodyName(i) = prt & "_" & bodies1.Item(i).name & "-" & i
add after name & "-" & i
RE: Part to Product Macro Issue
This saved me multiple hours of work renaming bodies.
Only complaint I have is when i have the following parts:
XXX
XXX
XXX
YYY
YYY
It gives me this as a result:
XXX_1
XXX_2
XXX_3
YYY_4
YYY_5
When I would rather have:
XXX_1
XXX_2
XXX_3
YYY_1
YYY_2
Any idea how to possibly accommodate this?
RE: Part to Product Macro Issue
RE: Part to Product Macro Issue
RE: Part to Product Macro Issue
I didn't test the following code, but if you rename something, I would put a unique string in the new name so you can detect if the body was already renamed and skip it...to speed up the macro. I used _# as my unique string, but if you find there are bodies already with that string, you may need something more complex so you can guarantee there are no bodies named that.
CODE -->