Can someone give me a pointer. I am using this doe I cobbled together/pinched and trying to get the filename to be (mostly) predetermined by user input on form. Got it all working, and the saveas dialog is prepopulated with the coirrect ino...but the file is not actually saving.???
Goes through the motions but nothing is happening. Any ideas?
If ThisDoc.Path = "" Then 'If Document has Not been saved before... 'SAVE AS DIALOG BOX 'define the active document oDoc = ThisDoc.Document 'create a file dialog box Dim oFileDlg As Inventor.FileDialog = Nothing InventorVb.Application.CreateFileDialog(oFileDlg) 'Set dialog filter 'oFileDlg.Filter = "Autodesk Inventor Part Files (*.ipt)|*.ipt" 'set the directory to open the dialog at 'oFileDlg.InitialDirectory = ThisDoc.WorkspacePath() 'set the file name string to use in the input box as the value entered in Excel Spreadsheet oFileDlg.FileName = iProperties.Value("Project","Project") & "-" & iProperties.Value("Summary","Category")& "-XXXX-" & iProperties.Value("Summary","Title") 'work with an error created by the user backing out of the save oFileDlg.CancelError = True On Error Resume Next 'specify the file dialog as a save dialog (rather than a open dialog) oFileDlg.ShowSave() 'catch an empty string in the imput If Err.Number <> 0 Then MessageBox.Show("No File Saved.", "Save: Dialog Canceled") ElseIf oFileDlg.FileName <> "" Then 'save the file oDoc.SaveAs(iProperties.Value("Project","Project") & "-" & iProperties.Value("Summary","Category"), False) 'True = Save As Copy & False = Save As Else End If End If
Solved! Go to Solution.
Solved by JhoelForshav. Go to Solution.
Hi @Anonymous
You need a file-extension (ex: .ipt, .iam) to save the document.
Try this 🙂
If ThisDoc.Path = "" Then 'If Document has Not been saved before... 'SAVE AS DIALOG BOX 'define the active document Dim oDoc As Document = ThisDoc.Document 'create a file dialog box Dim oFileDlg As Inventor.FileDialog = Nothing InventorVb.Application.CreateFileDialog(oFileDlg) 'Set dialog filter 'oFileDlg.Filter = "Autodesk Inventor Part Files (*.ipt)|*.ipt" 'set the directory to open the dialog at 'oFileDlg.InitialDirectory = ThisDoc.WorkspacePath() 'set the file name string to use in the input box as the value entered in Excel Spreadsheet oFileDlg.FileName = iProperties.Value("Project", "Project") & "-" & iProperties.Value("Summary", "Category") & "-XXXX-" & iProperties.Value("Summary", "Title") 'work with an error created by the user backing out of the save oFileDlg.CancelError = True On Error Resume Next 'specify the file dialog as a save dialog (rather than a open dialog) oFileDlg.ShowSave() 'catch an empty string in the imput If Err.Number <> 0 Then MessageBox.Show("No File Saved.", "Save: Dialog Canceled") ElseIf oFileDlg.FileName <> "" Then Dim oExt As String If oDoc.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then oExt = ".iam" If oDoc.DocumentType = DocumentTypeEnum.kPartDocumentObject Then oExt = ".ipt" If oDoc.DocumentType = DocumentTypeEnum.kDrawingDocumentObject Then oExt = ".dwg" oDoc.SaveAs(oFileDlg.FileName & oExt, False) 'True = Save As Copy & False = Save As End If End If
Jhoel Forshav
Download my free Inventor Addin - Hole Projector
LinkedIn | Ideas | Contributions | Blog posts | Website
But I think it's better to use the FileDialog filter for this:
If ThisDoc.Path = "" Then 'If Document has Not been saved before... 'SAVE AS DIALOG BOX 'define the active document Dim oDoc As Document = ThisDoc.Document 'create a file dialog box Dim oFileDlg As Inventor.FileDialog = Nothing InventorVb.Application.CreateFileDialog(oFileDlg) 'Set dialog filter If oDoc.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then oFileDlg.Filter = "Autodesk Inventor Assembly Files (*.iam)|*.iam" If oDoc.DocumentType = DocumentTypeEnum.kPartDocumentObject Then oFileDlg.Filter = "Autodesk Inventor Part Files (*.ipt)|*.ipt" If oDoc.DocumentType = DocumentTypeEnum.kDrawingDocumentObject Then oFileDlg.Filter = "Autodesk Inventor Drawing Files (*.dwg)|*.dwg" 'set the directory to open the dialog at 'oFileDlg.InitialDirectory = ThisDoc.WorkspacePath() 'set the file name string to use in the input box as the value entered in Excel Spreadsheet oFileDlg.FileName = iProperties.Value("Project", "Project") & "-" & iProperties.Value("Summary", "Category") & "-XXXX-" & iProperties.Value("Summary", "Title") 'work with an error created by the user backing out of the save oFileDlg.CancelError = True On Error Resume Next 'specify the file dialog as a save dialog (rather than a open dialog) oFileDlg.ShowSave() 'catch an empty string in the imput If Err.Number <> 0 Then MessageBox.Show("No File Saved.", "Save: Dialog Canceled") ElseIf oFileDlg.FileName <> "" Then oDoc.SaveAs(oFileDlg.FileName, False) 'True = Save As Copy & False = Save As End If End If
Jhoel Forshav
Download my free Inventor Addin - Hole Projector
LinkedIn | Ideas | Contributions | Blog posts | Website
Thanks. I was just tring your first solution.
I got it working as a standard rule, but wouldnt as an external rule.
Ill just try the new one now
Can't find what you're looking for? Ask the community or share your knowledge.