Hello,
I am new to the forum.
I am looking for a macro which exports my model file as a ".step" file. I would like it to name the ".step" file as "configuration name" - "document revision number".step. then place it in C:\.
Hello,
I am new to the forum.
I am looking for a macro which exports my model file as a ".step" file. I would like it to name the ".step" file as "configuration name" - "document revision number".step. then place it in C:\.
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Sub main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Dim confName As String
Dim revNmb As String
Dim fileName As String
confName = swModel.ConfigurationManager.ActiveConfiguration.Name
revNmb = swModel.Extension.CustomPropertyManager(confName).Get("Revision")
fileName = confName & " - " & revNmb & ".step"
swModel.Extension.SaveAs "c:\" & fileName, swSaveAsVersion_e.swSaveAsCurrentVersion, swSaveAsOptions_e.swSaveAsOptions_Silent, Nothing, 0, 0
End Sub
____________________________________________________
Regards,
Artem Taturevych, Application Engineer at Intercad (Australia)
translationXpert – add-in to translate SolidWorks models
I need the same only I would like to get my file saved as the same filename of the document in the same folder as the document.
Can anyone help me?
Here are the macro codes if you want to use the macro only:
Dim swApp As SldWorks.SldWorks Dim swModel As SldWorks.ModelDoc2 Sub main() Set swApp = Application.SldWorks Set swModel = swApp.ActiveDoc swModel.Extension.SaveAs Left(swModel.GetPathName, InStrRev(swModel.GetPathName, ".")) & "STEP", 0, 0, Nothing, 0, 0 End Sub
Hi Deepak,
Do you have macro to convert all the part files in a particular folder to STEP?
Your code works fine for the active window part.
i have 400 part files to be converted to STEP.
Regards,
Prasanna.A
Try these codes
Option Explicit
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim sFileName As String
Dim Path As String
Dim nErrors As Long
Dim nWarnings As Long
Sub main()
On Error Resume Next
Set swApp = Application.SldWorks
Path = "C:\SolidWorks to Step File\" 'Change path here and make sure you include \ at end of path.
sFileName = Dir(Path & "*.sldprt")
Do Until sFileName = ""
Set swModel = swApp.OpenDoc6(Path + sFileName, swDocPART, swOpenDocOptions_Silent, "", nErrors, nWarnings)
Set swModel = swApp.ActiveDoc
swModel.Extension.SaveAs Left(swModel.GetPathName, InStrRev(swModel.GetPathName, ".")) & "STEP", 0, 0, Nothing, 0, 0
swApp.CloseDoc swModel.GetTitle
Set swModel = Nothing
sFileName = Dir
Loop
End Sub
Hi Deepak,
Thank you for the code. Works perfect.
Is it possible to set output folder in this?
Thank you, saved lot of time.
Regards,
Prasanna.A
Yes, use the codes from the macro in this post: https://forum.solidworks.com/message/660444#comment-660444
Hello. This macro would really be helpful but I can't get it to work??? I have created a new macro and added the code but nothing happens. Can you please help?
Thank you
Steve
Steve Bondy wrote:
Hello. This macro would really be helpful but I can't get it to work??? I have created a new macro and added the code but nothing happens. Can you please help?
Thank you
Steve
If you are using macro for batch processing then make sure you change the path in this line
Path = "C:\SolidWorks to Step File\"
Steve Bondy wrote:
Did that and still doesn't work. Will this macro work with SW2019?
Yes but make sure that you set the references in your macro to 2019 version as suggested here Fix-Update SOLIDWORKS Macro References (don't worry on the fact that video is for fixing missing library error but check the process to update your macro library)
____________________________________________________
Regards,
Artem Taturevych, Application Engineer at Intercad (Australia)
translationXpert – add-in to translate SolidWorks models
LinkedIn SolidWorks API Education Group