Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Solidworks API help - saving a part

Status
Not open for further replies.

bOILERbRAD

Mechanical
Aug 11, 2008
17
Hey guys,

Can anyone tell me why this code is not saving my part?

pDirectory = "M:\Solidworks\Tooling\Inspect\" & tooltbx.Text & "\" & tooltbx.Text & ".sldprt"
If MsgBox("Save as " & pDirectory & "?", vbOKCancel, "Confirm Save") = vbOK Then
Part.Extension.SaveAs pDirectory, 0, 2, Nothing, longstatus, longwarnings
If MsgBox("Make a drawing?", vbOKCancel, "Create Drawing?") = vbCancel Then
End
End If
Else
Exit Sub
End If
 
Replies continue below

Recommended for you

Hey, guy!

Can you tell us what sort of thing actually does happen?

-handleman, CSWP (The new, easy test)
 
I figured it out. As is, the code does absolutely nothing. I changed the save command and added some code that created the appropriate folder if it does not exist and that solved my problems. Here is that code if you were wondering.

FOLDER = "M:\Solidworks\Tooling\Inspect\" & tooltbx.Text
Set FSO = CreateObject("Scripting.FileSystemObject")
If Not FSO.FolderExists(FOLDER) Then
FSO.createFolder (FOLDER)
End If

pDirectory = "M:\Solidworks\Tooling\Inspect\" & tooltbx.Text & "\" & tooltbx.Text & ".SLDPRT"
If MsgBox("Save as " & pDirectory & "?", vbOKCancel, "Confirm Save") = vbOK Then
Part.SaveAs2 pDirectory, 0, False, False
If MsgBox("Make a drawing?", vbOKCancel, "Create Drawing?") = vbCancel Then
End
End If
Else
Exit Sub
End If
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor