Here is a macro to batch export all parts in selected folder as STEP file which will be saved in the same folder.
Macro libraries are set to SW2019 version. In case you're running a different version then update/correct the macro references as suggested in this video (don't worry on the fact that video is for fixing missing library error but check the process to update your macro library):
Also you can change the format from STEP to other formats as needed.
Batch Export as STEP (Parts Only)
Batch Export as STEP (Parts Only)
- Attachments
-
- Batch Export STEP File (Parts)-2019.swp
- (42 KiB) Downloaded 705 times
Deepak Gupta
SOLIDWORKS Consultant/Blogger
SOLIDWORKS Consultant/Blogger
Re: Batch Export as STEP (Parts Only)
I'm curious. What's the advantage of doing this with a macro over Solidworks Task Scheduler?gupta9665 wrote: ↑Fri May 07, 2021 9:22 am Here is a macro to batch export all parts in selected folder as STEP file which will be saved in the same folder.
Macro libraries are set to SW2019 version. In case you're running a different version then update/correct the macro references as suggested in this video (don't worry on the fact that video is for fixing missing library error but check the process to update your macro library):
Also you can change the format from STEP to other formats as needed.
Re: Batch Export as STEP (Parts Only)
I know mainly below reasons:
1. You can export multiple version in same go
2. Using macro is faster compared to TS.
Deepak Gupta
SOLIDWORKS Consultant/Blogger
SOLIDWORKS Consultant/Blogger
-
- Posts: 1
- Joined: Mon Jan 06, 2025 11:09 pm
- x 1
Re: Batch Export as STEP (Parts Only)
Hi, Thanks for the Macro. I don't know writing macro program. Your Macro is working excellent. Your code converts to step AP203 format. Could you please modify your code to save the Step file in STEP214 format? I downloaded from another forum for STEP AP214 format. Unfortunately, it is working for only one file. Could you please modify to same folder selection like yours? Appreciate your help. I could not afford to invest on Solidworks Premium. I have only solidworks standard version only. So your macro is going to help a lot. Below AP214 code for your reference.
Option Explicit
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swModelActivated As SldWorks.ModelDoc2
Dim swModelToExport As SldWorks.ModelDoc2
Dim strModelName As String
Dim nStatus As Long
Dim nErrors As Long
Dim nWarnings As Long
Sub SaveToStep()
'Declare variables
Dim OutputCoordSys As String
Dim FileToExport As String
Dim StepFile As String
Set swApp = Application.SldWorks
FileToExport = "C:\Users\a8280\Desktop\Output\ME10008326..SLDPRT"
OutputCoordSys = "Coordinate System Test"
StepFile = Replace(FileToExport, ".SLDPRT", ".STEP")
'Open
Set swModel = swApp.OpenDoc6(FileToExport, 1, 0, "", nStatus, nWarnings)
'Activate the model
strModelName = swModel.GetTitle
Set swModelActivated = swApp.ActivateDoc3(strModelName, False, swRebuildOnActivation_e.swUserDecision, nErrors)
'Get the active model
Set swModelToExport = swApp.ActiveDoc
'Assign correct STEP
swApp.SetUserPreferenceIntegerValue swUserPreferenceIntegerValue_e.swStepAP, 214
'Set Export appearences option to true
swApp.SetUserPreferenceToggle swUserPreferenceToggle_e.swStepExportAppearances, True
'Assign Output coordinate system to use
swApp.SetUserPreferenceStringValue swUserPreferenceStringValue_e.swExportOutputCoordinateSystem, OutputCoordSys
'Save the file as step
swModelToExport.Extension.SaveAs3 StepFile, 0, 1, Nothing, Nothing, nErrors, nWarnings
End Sub
Option Explicit
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swModelActivated As SldWorks.ModelDoc2
Dim swModelToExport As SldWorks.ModelDoc2
Dim strModelName As String
Dim nStatus As Long
Dim nErrors As Long
Dim nWarnings As Long
Sub SaveToStep()
'Declare variables
Dim OutputCoordSys As String
Dim FileToExport As String
Dim StepFile As String
Set swApp = Application.SldWorks
FileToExport = "C:\Users\a8280\Desktop\Output\ME10008326..SLDPRT"
OutputCoordSys = "Coordinate System Test"
StepFile = Replace(FileToExport, ".SLDPRT", ".STEP")
'Open
Set swModel = swApp.OpenDoc6(FileToExport, 1, 0, "", nStatus, nWarnings)
'Activate the model
strModelName = swModel.GetTitle
Set swModelActivated = swApp.ActivateDoc3(strModelName, False, swRebuildOnActivation_e.swUserDecision, nErrors)
'Get the active model
Set swModelToExport = swApp.ActiveDoc
'Assign correct STEP
swApp.SetUserPreferenceIntegerValue swUserPreferenceIntegerValue_e.swStepAP, 214
'Set Export appearences option to true
swApp.SetUserPreferenceToggle swUserPreferenceToggle_e.swStepExportAppearances, True
'Assign Output coordinate system to use
swApp.SetUserPreferenceStringValue swUserPreferenceStringValue_e.swExportOutputCoordinateSystem, OutputCoordSys
'Save the file as step
swModelToExport.Extension.SaveAs3 StepFile, 0, 1, Nothing, Nothing, nErrors, nWarnings
End Sub