In diesem Video zeige ich das speichern von Solidworks Dateien in das STEP Format und als Bilddatei.
Und an dieser Stelle der Code der im Makro vorhanden ist.
Option Explicit
Sub main()
Dim swApp As SldWorks.SldWorks
Set swApp = Application.SldWorks
Dim swModel As ModelDoc2
Set swModel = swApp.ActiveDoc
If swModel Is Nothing Then
swApp.SendMsgToUser "Kein Dokument geladen."
Exit Sub
End If
Dim Errors As Long
Dim Warnings As Long
Dim FullName As String
Dim ReturnValue As Boolean
FullName = swModel.GetPathName
If swModel.GetType = swDocPART Or swModel.GetType = swDocASSEMBLY Then
FullName = Left(FullName, Len(FullName) - 6) & "step"
Dim tempUserPref As Integer
tempUserPref = swApp.GetUserPreferenceIntegerValue(swUserPreferenceIntegerValue_e.swStepAP)
swApp.SetUserPreferenceIntegerValue swUserPreferenceIntegerValue_e.swStepAP, 214 '203/214
ReturnValue = swModel.Extension.SaveAs3(FullName, swSaveAsVersion_e.swSaveAsCurrentVersion, swSaveAsOptions_Silent, Nothing, Nothing, Errors, Warnings)
Debug.Print "Errors: " & Errors
Debug.Print "Warnings: " & Warnings
Debug.Print "Return Value: " & ReturnValue
swApp.SetUserPreferenceIntegerValue swUserPreferenceIntegerValue_e.swStepAP, tempUserPref
End If
FullName = Left(FullName, Len(FullName) - 6) & "jpg"
ReturnValue = swModel.Extension.SaveAs3(FullName, swSaveAsVersion_e.swSaveAsCurrentVersion, swSaveAsOptions_Silent, Nothing, Nothing, Errors, Warnings)
End Sub