iLogic - Filling out Save As Filename

iLogic - Filling out Save As Filename

Anonymous
Not applicable
1,842 Views
3 Replies
Message 1 of 4

iLogic - Filling out Save As Filename

Anonymous
Not applicable

I have a template .ipt file which I would like to save when I create a new document as a specific filename, which i will edit once the save dialog box appears.  I would like the file name to be "FLAT BAR-" so I can add numbers to the end of it to differentiate my parts.  So far my code can open the save dialog box, call it "FLAT BAR-" and make the file type a .ipt.  When I hit the save button however, it does not save.  It also does not save after I make it "FLAT BAR-1" or "FLAT BAR-2".  Any help would be great (new to iLogic).

 

 

oDoc = ThisDoc.Document

Dim oFileDlg As inventor.FileDialog = Nothing
InventorVb.Application.CreateFileDialog(oFileDlg)

oFileDlg.Filter = "Autodesk Inventor Part Files (*.ipt)|*.ipt"

oFileDlg.FileName =  "FLAT BAR-"

oFileDlg.ShowSave()
0 Likes
Accepted solutions (2)
1,843 Views
3 Replies
Replies (3)
Message 2 of 4

BrandonBG
Collaborator
Collaborator
Accepted solution

http://forums.autodesk.com/t5/inventor-general-discussion/selecting-save-as-directory-with-ilogic/td...

 

This worked for me.

 

You may need to add the error check.

 

BrandonBG
Inventor2015

 

 

0 Likes
Message 3 of 4

ekinsb
Alumni
Alumni
Accepted solution

The file dialog doesn't actually perform the save.  It's used to have a consistent interface anytime you need to ask the user for a filename.  For example, you could also use it to ask the user for the filename of a report you want to save.  After the ShowSave you can use the Filename property to get the filename that was set and then use the Document.SaveAs method to save the document to that file.  The second argument to the SaveAs method should be False so you do a Save As instead of a Save Copy As.  A Save As is what Inventor does when you save a document for the first time.


Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
0 Likes
Message 4 of 4

Anonymous
Not applicable

Thank both of you.  I was able to use the end of that code to initiate the save.  The code is as follows.

 

oDoc = ThisDoc.Document

Dim oFileDlg As inventor.FileDialog = Nothing
InventorVb.Application.CreateFileDialog(oFileDlg)

oFileDlg.Filter = "Autodesk Inventor Part Files (*.ipt)|*.ipt"

oFileDlg.FileName =  "FLAT BAR-"

oFileDlg.ShowSave()

MyFile = oFileDlg.FileName

oDoc.SaveAs(MyFile, False)
0 Likes