×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Solidworks API help - saving a part

Solidworks API help - saving a part

Solidworks API help - saving a part

(OP)
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

RE: Solidworks API help - saving a part

Hey, guy!

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

-handleman, CSWP (The new, easy test)

RE: Solidworks API help - saving a part

(OP)
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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources