AnsweredAssumed Answered

How to hard code save location in a EPDM Task Script

Question asked by Emil Svallingson on Oct 2, 2013
Latest reply on Oct 9, 2013 by Emil Svallingson

Hi,

 

I have the following scipt which is working great. However I want the outcome ( a part file and a step file) to end up in the L:\Temp folder, always. How do I hard code that in?

 

This is script right now:

 

Dim swApp          As SldWorks.SldWorks
Dim swModel        As SldWorks.ModelDoc2
Dim swModelDocExt  As SldWorks.ModelDocExtension
Dim FilePath        As String
Dim sFilePath      As String
Dim PathSize        As Long
Dim PathNoExtensionAs String
Dim NewFilePath    As String
Dim nErrors        As Long
Dim nWarnings      As Long

 

Sub main()

 

Set swApp = Application.SldWorks

'Set swModel = swApp.ActiveDoc

Set swModel = swApp.OpenDoc6("<Filepath>", SwConst.swDocASSEMBLY, 3, "", nErrors, nWarnings)

 

Set swModelDocExt = swModel.Extension

 

FilePath = swModel.GetPathName

PathSize = Strings.Len(FilePath)

PathNoExtension = Strings.Left(FilePath, PathSize - 6)

NewFilePath = PathNoExtension & "SLDPRT"

 

swApp.SetUserPreferenceIntegerValue swSaveAssemblyAsPartOptions, swSaveAsmAsPart_ExteriorFaces

swModelDocExt.SaveAs NewFilePath, swSaveAsCurrentVersion, swSaveAsOptions_Silent, Nothing, nErrors, nWarnings

'swApp.CloseDoc swModel.GetTitle

 

Set swModel = swApp.OpenDoc6(NewFilePath, SwConst.swDocPART, 3, "", nErrors, nWarnings)

Set swModel = swApp.ActiveDoc

 

sFilePath = PathNoExtension & "STEP"

swModel.SaveAs (sFilePath)

swApp.CloseDoc swModel.GetTitle

 

End Sub

Outcomes