Koray Karaman

About Koray Karaman Categories Home Music Photos Files
Posts
Files
About
Categories
Music
Projects
Photos
Go Back
21.09.2019 16:47
PERMALINK

Deneme 3
Database Engineering
.NET & C# Programming
Like3279 Reactions

Solidworks 2019 Save As PDF, DXF, DWG Macro


Sub main()

Dim swApp As SldWorks.SldWorks
Dim Part As SldWorks.ModelDoc2
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long
Dim value As Boolean
Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc

' Zoom To Fit
Part.ViewZoomtofit2
 
    If Part.GetPathName = "" Then
            If Not swApp.RunCommand(swCommands_e.swCommands_SaveAs, Empty) Then
                swApp.SendMsgToUser2 "Error: Command save as couldn't run.", swMessageBoxIcon_e.swMbStop, swMessageBoxBtn_e.swMbOk
            End If
        Else
            If Not swApp.RunCommand(swCommands_e.swCommands_Save, Empty) Then
                swApp.SendMsgToUser2 "Error: File couldn't saved.", swMessageBoxIcon_e.swMbStop, swMessageBoxBtn_e.swMbOk
            End If
        End If



If Not Part Is Nothing Then
    
FileTyp = Part.GetType
 
Dim FilePath As String
Dim PathSize As Long
Dim PathNoExtension As String
Dim NewFilePath As String
Dim NewFileEXT As String


FilePath = Part.GetPathName
PathSize = Strings.Len(FilePath)
PathNoExtension = Strings.Left(FilePath, PathSize - 6)



Part.ClearSelection2 True

' Save As
'NewFileEXT = "SLDDRW"
'NewFilePath = PathNoExtension & NewFileEXT
'longstatus = Part.SaveAs3(NewFilePath, 0, 2)

' Save As
NewFileEXT = "PDF"
NewFilePath = PathNoExtension & NewFileEXT
longstatus = Part.SaveAs3(NewFilePath, 0, 0)
Part.SheetPrevious

' Redraw
Part.GraphicsRedraw2

' Save As
NewFileEXT = "DXF"
NewFilePath = PathNoExtension & NewFileEXT
longstatus = Part.SaveAs3(NewFilePath, 0, 0)

MsgBox "SLDDRW, PDF and DXF saved successfully.", vbInformation



Else
      MsgBox "There is no part to save." & Chr(13) & Chr(13) _
            & "Load Part/Assembly and try again.", vbExclamation
    End If

End Sub

Koray Karaman

Browse on Mobile

MySQL Monitoring on Zabbix 3.4 deneme postu 2173 counter ile
Facebook Twitter Instagram Github
© 2006—2026 Koray Karaman