Pattabi Kakumanu

Save as DXF file with filename+Version(Revision)

Discussion created by Pattabi Kakumanu on Oct 23, 2020
Latest reply on Oct 23, 2020 by Deepak Gupta

Deepak Gupta @ need help! 

I'm very new to macros world. But I have written a macro that allows open drawing to save as "DXF file" in the predefined location in the code. My macro code only saves the "DXF file" with the document name but I want to save with document name+Version(Revision). 

Thanks in advance.

 

My code

Sub Main()

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

If swModel Is Nothing Then
MsgBox ("Open a Model")
Exit Sub
End If

newExtension = ".dxf"

Select Case swModel.GetType


Case swDocDRAWING
currExtension = ".slddrw"

Case swDocPART
MsgBox ("Part can't " + newExtension)

Case swDocASSEMBLY
MsgBox ("Assembly can't " + newExtension)

Exit Sub
End Select

Path = "F:\Daten\CAD_Konstruktion\PK
If Path = "" Then
MsgBox "Please select the path and try again"
End
Else
Path = Path & "\"
End If

strNewPath = Path + Replace(Mid(swModel.GetPathName, InStrRev(swModel.GetPathName, "\") + 1), currExtension, newExtension, 1, 1, vbTextCompare)

'strNewPath = Replace(swModel.GetPathName, currExtension, newExtension, 1, 1, vbTextCompare)

swModel.extension.SaveAs strNewPath, 0, swSaveAsOptions_Silent, Nothing, lngErrors, lngWarnings

End Sub

Attachments

Outcomes