Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Saveas Ilogic not saving??

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
Anonymous
536 Views, 3 Replies

Saveas Ilogic not saving??

 

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

 

3 REPLIES 3
Message 2 of 4
JhoelForshav
in reply to: Anonymous

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
Message 3 of 4
JhoelForshav
in reply to: JhoelForshav

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
Message 4 of 4
Anonymous
in reply to: JhoelForshav

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.

Post to forums  

Technology Administrators


Autodesk Design & Make Report