Hello
It's me again on a macro subject.
I want to export my solidworks files (Assembly and Part) in STEP (if possible AP214) with at the end of the file name the revision index and then the export date (so of the day).
By getting macros and tips from all over the forum, I managed to do it for my DXF and PDF exports but I have trouble with the STEP where I can only integrate the date but I don't understand how to retrieve the revision index (tab " Customize " of the "Properties").
Below is my current code:
’ *******************************************
' I want to export my file to \STEP
’ *******************************************
Option Explicit
Dim swApp As SldWorks.SldWorks
Dim Part As SldWorks.ModelDoc2
Dim boolstatus As Boolean
Dim sFilePath As String
Dim FileName As String
Dim DateiMitPfad As String
Dim Errors As Long
Dim Warnings As Long
Sub main()
Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
If Part Is Nothing Then End
File Saving Status
DateiMitPfad = Part.GetPathName()
If DateiMitPfad = " " Then
MsgBox (" Please save the file before this macro runs! ")
Part.Save
End If
' We retrieve the current date and put it in a format that can be put in the name of a file
Dim dateNow As String
dateNow = Replace(Date, " / ", " . ")
sFilePath = Left(Part.GetPathName, InStrRev(Part.GetPathName, ""))
FileName = Mid(Part.GetPathName, InStrRev(Part.GetPathName, "") + 1)
FileName = Left(FileName, InStrRev(FileName, " . ") - 1)
FileName = sFilePath & "" & FileName
Part.SaveAs2 FileName + " - " & dateNow & ". STEP ", 0, True, False
End Sub
Thank you in advance for your feedback