Macro to save all parts in assembly as step files?

rosenrob
Posts: 7
Joined: Tue Apr 06, 2021 2:19 pm
Answers: 0
x 12
x 7

Macro to save all parts in assembly as step files?

Unread post by rosenrob »

First post! I migrated over here because the new SW forum is unusable.

I'm looking for a macro to save all the parts in a given assembly as step files. I found some stuff on the old SW forum but all the links seem to be gone. Does anyone know of anything?

Thank you!
User avatar
matt
Posts: 1576
Joined: Mon Mar 08, 2021 11:34 am
Answers: 19
Location: Virginia
x 1211
x 2358
Contact:

Re: Macro to save all parts in assembly as step files?

Unread post by matt »

Welcome! We seem to have a pretty API savvy group here, so hopefully someone can get you sorted out. Thanks for posting!
User avatar
mattpeneguy
Posts: 1386
Joined: Tue Mar 09, 2021 11:14 am
Answers: 4
x 2489
x 1899

Re: Macro to save all parts in assembly as step files?

Unread post by mattpeneguy »

Yes, I know @artem posted a link to all his macros and that one is there (also a lot more. Thanks Artem!). Let me do some digging and I'll post a link here.
User avatar
mattpeneguy
Posts: 1386
Joined: Tue Mar 09, 2021 11:14 am
Answers: 4
x 2489
x 1899

Re: Macro to save all parts in assembly as step files?

Unread post by mattpeneguy »

Forgot to extend a hello and welcome...So, hello and welcome to the forum!
Here's the link to @artem's macros:
https://www.codestack.net/solidworks-tools/

Get the one that's closest to what you need and post back here if you need help. As Matt posted, there are some good programmers here that can help (I'll pitch in, but my advice compared to theirs' is nowhere near as good).
User avatar
Frederick_Law
Posts: 1931
Joined: Mon Mar 08, 2021 1:09 pm
Answers: 8
Location: Toronto
x 1616
x 1455

Re: Macro to save all parts in assembly as step files?

Unread post by Frederick_Law »

Export the assembly to STEP or X_T and other can import and all the parts.
Usually with correct file name.

Exporting each part will require assemble.
User avatar
matt
Posts: 1576
Joined: Mon Mar 08, 2021 11:34 am
Answers: 19
Location: Virginia
x 1211
x 2358
Contact:

Re: Macro to save all parts in assembly as step files?

Unread post by matt »

Remember that if you want to share a macro, one great way to make sure it gains visibility is to use the Upload function in the menu bar at the top of the window. This way all the macros can be in one easy to search location.
User avatar
DanPihlaja
Posts: 819
Joined: Thu Mar 11, 2021 9:33 am
Answers: 25
Location: Traverse City, MI
x 791
x 952

Re: Macro to save all parts in assembly as step files?

Unread post by DanPihlaja »

mattpeneguy wrote: Thu May 06, 2021 2:22 pm Yes, I know @artem posted a link to all his macros and that one is there (also a lot more. Thanks Artem!). Let me do some digging and I'll post a link here.
Should be here:
https://www.codestack.net/solidworks-tools/
-Dan Pihlaja
Solidworks 2022 SP4

2 Corinthians 13:14
artem
Posts: 26
Joined: Thu Mar 18, 2021 1:31 pm
Answers: 3
x 9
x 74

Re: Macro to save all parts in assembly as step files?

Unread post by artem »

@rosenrob , you can use this macro: https://www.codestack.net/solidworks-ap ... i-formats/. It is pretty flexible with output folder and file naming (you can use a combination of free text, file name, custom property value etc.) and you can even use this to generate sub-folders. This macro runs on a single file. But you can combine this with free Batch+ for assemblies to run on all (or selected components) in the assembly: https://cadplus.xarial.com/batch/assembly/. Here is a short demo (although the UI there is from a newer, not yet released version), but it will give you an idea:
Thanks,
Artem
xarial.com - making your CAD better
codestack.net - SOLIDWORKS API macros and tutorials
rosenrob
Posts: 7
Joined: Tue Apr 06, 2021 2:19 pm
Answers: 0
x 12
x 7

Re: Macro to save all parts in assembly as step files?

Unread post by rosenrob »

Damn you guys are quick! Thank you for all the help. I was originally hoping to be able to do this through Solidworks PDM which I have set up to create pdf's when I release an assembly. Turns out you need the pro version to do that with step file, so here I am.

@artem, I'll give that macro a shot this morning. I am pretty new to macros so I may be back with questions.
rosenrob
Posts: 7
Joined: Tue Apr 06, 2021 2:19 pm
Answers: 0
x 12
x 7

Re: Macro to save all parts in assembly as step files?

Unread post by rosenrob »

@artem, it works like a dream.

Thanks for the help everyone. Now time to dive deeper into the rabbit hole of macros.
jluie85
Posts: 1
Joined: Tue May 02, 2023 3:12 pm
Answers: 0

Re: Macro to save all parts in assembly as step files?

Unread post by jluie85 »

Hello,

I am using solidworks 2019 With PDM. I have been Testing with multi format export

https://www.codestack.net/solidworks-ap ... i-formats/

The macro works really good but I would like it to Name the drawing file with the part revision. Im not sure the input for that. I know solidworks has this for pulling revision from other areas but that does work "($PRPSHEET:{Revision})" I also cant get the macro to stop saving the part as a .PDF

The inputs I have used
OUT_NAME_TEMPLATES = Array("<_FileName_><Revision>.pdf", "<_FileName_><Revision>.x_t")
image.png

We also Use PDM data card but I have tried "Dwg Rev"

image.png
image.png
Post Reply