Hi,
I am using a macro inside of Solidworks which works perfectly and now I am trying to insert this macro into a EDPM task with fatal results. How do I do this?
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
'------------------
SolidworksSolidworks Pdm enterprise Pdm