AnsweredAssumed Answered

How to insert macro into EPDM task?

Question asked by Emil Svallingson on Sep 27, 2013
Latest reply on Oct 15, 2013 by Deepak Gupta

I have a macro working perfectly in SW but how do I insert it succesfully into a new EPDM task? This is the macro I am using:

 

 

' Save Assy As Part (Exterior Surfaces).swp ---------------------------06/16/12

'

'Description: Macro to save assembly to save as part (Exterior Surfaces).

'             Then saved part file is further saved as "STEP" file in the same location.

'

'Precondition: Any active assembly with minimum one part.

'

'Postcondition: Assembly is saved as part and part is saved as "STEP" file.

'

' ------------------------------------------------------------------------------

' Written by: Deepak Gupta (http://gupta9665.wordpress.com/)

' ------------------------------------------------------------------------------

 

 

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 PathNoExtension     As String

Dim NewFilePath         As String

Dim nErrors             As Long

Dim nWarnings           As Long

 

 

Sub main()

 

 

Set swApp = Application.SldWorks

Set swModel = swApp.ActiveDoc

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.OpenDoc(NewFilePath, swDocPART)

Set swModel = swApp.ActiveDoc

 

 

sFilePath = PathNoExtension & "STEP"

 

swModel.SaveAs (sFilePath)

 

 

swApp.CloseDoc swModel.GetTitle

 

 

End Sub

'------------------

Outcomes