Macro copy part in assembly

I would like advice on how to copy a part in an assembly using a macro than I want to make the part unique and rename it.

I got stuck right at the beginning. I want to select the part and make a copy, but the part cannot be copied…

Can someone help me?

MACRO main

[vxGetEntity,"vyber","/comp/",EntList, EntCnt]
[vxSend,"~CdCopy"]
[vxSend,"~CdPaste"]

ENDMACRO

Why build a macro when the tool already exists?

Cheers, Paul

I want to make a macro that copies a part and creates the same one with position +1. You have to do the sequence select part + copy part + paste part + make unique part + rename part. The newly created part will of course be geometrically different from the one it was based on. For example, you have an aluminum profile and you want a different length, etc.

If you use this 100 times a day then I think the macro makes sense.

What do you mean the tool already exists?

I would really appreciate it if someone could give me an answer instead of me explaining why I actually need it.

Thank you

Open the part or assembly,
RMB of the Object Name in the Tree.
Choose Make All Copy
Add you suffix. (You have to re tick boxes to deselect.)
Pick the Objects, files you wish to rename or both.
Activate the renaming by suffix, by clicking buttons 3 or 4.
Save and Open Option.
Look at the Tab Title to check which item you are editing.
Use Change Component to swap the new names and length part into the assembly.
Constraints that make sense should still work.
image
For individual objects or Files Save As Takes you to an option to to do the same thing.
In 2024 we get this, which should be on the disrt page, less is better right,
image

But in 2025 we have improvements, like this.
image

Cheers, Paul

1 Like

Thank you Paul.

Can someone help me with this macro?

@Petrnejedly
code :point_down::point_down::point_down::point_down::point_down:


MACRO main
[vxGetEntity,"Hello","/comp/,empty_ok,limit=1",G_comp] 
[vxSend,G_comp,"~CdCopy"]
[vxSend,"~CdPaste"]
ENDMACRO

Thank you very much.

I have tried it in ZW3D 2025 and it show me this warning “WARNING: [538] is not a valid selection.” on the line below:

[vxSend,G_comp,"~CdCopy"]

Any idea what to do with it?

thank you