AnsweredAssumed Answered

Export step with user specified BOM PN & Revision

Question asked by Jonas Concepcion on Jun 23, 2020
Latest reply on Jun 25, 2020 by Jonas Concepcion



I was wondering if I could get some insight on how to modify a Deepak Gupta macro I found which exports the current configuration into a step file. I would just like it to be able to produce a filename with the user specified name for the Part Number used in BOMs and the current Revision. 



So with the above example it would be L006-01 RevB.STEP





Option Explicit

Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim strModelName As String
Dim nErrors As Long
Dim nWarnings As Long

Sub Main()

Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc

If swModel Is Nothing Then
MsgBox "Please open a PART file!", vbOKOnly + vbExclamation
End If

' make sure open document is a Part file
If swModel.GetType = swDocDRAWING Then
MsgBox "The Active document is not a Part file." & vbCrLf & _
"This macro only works for Part files.", vbOKOnly + vbExclamation
End If

'check if file has been saved already
If swModel.GetPathName = "" Then
MsgBox "Save the Part file first!", vbOKOnly + vbExclamation
End If

' set STEP version to 214
swApp.SetUserPreferenceIntegerValue swUserPreferenceIntegerValue_e.swStepAP, 214

' get file full name without extension
strModelName = Left(swModel.GetPathName, InStrRev(swModel.GetPathName, "."))
' save as STEP
swModel.Extension.SaveAs strModelName & "STEP", 0, swSaveAsOptions_e.swSaveAsOptions_Silent, Nothing, nErrors, nWarnings

End Sub


Thank you.