iLogic: Did SaveAs fails in 2019

iLogic: Did SaveAs fails in 2019

corym
Advocate Advocate
884 Views
4 Replies
Message 1 of 5

iLogic: Did SaveAs fails in 2019

corym
Advocate
Advocate

Hello,

I had an ilogic rule that triggered when I started a new part or assembly file.

It would take the part number property, and split it up, create a filepath from the information, and then save the file to that location.

 

After installing 2019, this seems to be broken. It seems to hang on the:

 

oDoc.SaveAs(oNewNamePurchased, False)

Has something changed in 2019 to break this code?

 

If ThisDoc.Path="" Then
    'If document has not been saved before...
	If iProperties.Value("Project", "Part Number") <> "" Then
	'part number property is blank then do not autosave
    
		If iProperties.Value("Project", "Description") = "" Then
		    'If the Description is empty...
		    ' GiveDescription=MessageBox.Show("You have not given this part a Description (Component name). Would you like to do so now?", "Missing Description",MessageBoxButtons.YesNo,MessageBoxIcon.Exclamation)
		    ' If GiveDescription=DialogResult.Yes Then
		        'If the user wants to provide a Description...
		        iProperties.Value("Project", "Description") = InputBox("Please Enter Description:", "Part Description", "")
		    ' End If
		End If
		
		'define the active document
		oDoc = ThisDoc.Document
		
		Dim oType As String
		Select Case oDoc.DocumentType
		Case kPartDocumentObject:     oType = ".ipt"
		Case kAssemblyDocumentObject: oType = ".iam"
		Case kDrawingDocumentObject:  oType = ".idw"
		End Select

		
		'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 = "C:\Vault-Local\Designs\"
		'set the file name string to use in the input box as the value entered in Excel Spreadsheet
		oFileDlg.FileName = iProperties.Value("Project", "Part Number")
		oName = iProperties.Value("Project", "Part Number")

		'grab first 2 characters of filename
		oFolder1 = Left(oName, + 2)
		
		'If filename begins with V- then save to purchased folder
		If oFolder1 = "V-" Then
			oFolderPurchased = "V-XXXXXXX"
			
			Dim oPathPurchased As String
			oPathPurchased = "C:\Vault-Local\Designs\" & oFolderPurchased & "\"
			
			Dim oNewNamePurchased As String
			oNewNamePurchased = oPathPurchased & oName & oType

			'MessageBox.Show(oNewNamePurchased, "Generated filepath")
			oDoc.SaveAs(oNewNamePurchased, False)
		End If
		
		'If filename does not begin with V- then save to the correct production folder
		If oFolder1 <> "V-" Then
			'Grab first 4 characters of filename and then drop first 2, keeping 3rd and 4th
			oFolder2a = Left(oName, + 4)
			oFolder2 = Right(oFolder2a, + 2)
		
			Dim oPath As String
			oPath = "C:\Vault-Local\Designs\" & oFolder1 & "\" & oFolder2 & "\"

			Dim oNewName As String
			oNewName = oPath & oName & oType

			'MessageBox.Show(oNewName, "Generated filepath")
			oDoc.SaveAs(oNewName, False)
		End If

		'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)
		'.ShowSave()

		'catch an empty string in the imput
		If Err.Number <> 0 Then
			MessageBox.Show("No File Saved.", "iLogic: Dialog Canceled")
			'ElseIf oFileDlg.FileName <> "" Then 

			'save the file
			'oDoc.SaveAs(oPath, Filename, True) 'True = Save As Copy & False = Save As
		End If
		Else
		'If document has been saved before...
		Return
	End If
End If
Cory McConnell
0 Likes
Accepted solutions (1)
885 Views
4 Replies
Replies (4)
Message 2 of 5

bradeneuropeArthur
Mentor
Mentor

You forgot the declaration:

If ThisDoc.Path = "" Then
    'If document has not been saved before...
	If iProperties.Value("Project", "Part Number") <> "" Then
	'part number property is blank then do not autosave
    
		If iProperties.Value("Project", "Description") = "" Then
		    'If the Description is empty...
		    ' GiveDescription=MessageBox.Show("You have not given this part a Description (Component name). Would you like to do so now?", "Missing Description",MessageBoxButtons.YesNo,MessageBoxIcon.Exclamation)
		    ' If GiveDescription=DialogResult.Yes Then
		        'If the user wants to provide a Description...
		        iProperties.Value("Project", "Description") = InputBox("Please Enter Description:", "Part Description", "")
		    ' End If
		End If
		
		'define the active document
		Dim odoc As Document
		odoc = ThisDoc.Document
		MsgBox (odoc.FullDocumentName)
		Dim oType As String
		Select Case oDoc.DocumentType
		Case kPartDocumentObject : oType = ".ipt"
		Case kAssemblyDocumentObject: oType = ".iam"
		Case kDrawingDocumentObject:  oType = ".idw"
		End Select

		
		'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 = "C:\Vault-Local\Designs\"
		'set the file name string to use in the input box as the value entered in Excel Spreadsheet
		oFileDlg.FileName = iProperties.Value("Project", "Part Number")
		oName = iProperties.Value("Project", "Part Number")

		'grab first 2 characters of filename
		oFolder1 = Left(oName, + 2)
		
		'If filename begins with V- then save to purchased folder
		If oFolder1 = "V-" Then
			oFolderPurchased = "V-XXXXXXX"
			
			Dim oPathPurchased As String
			oPathPurchased = "C:\Vault-Local\Designs\" & oFolderPurchased & "\"
			
			Dim oNewNamePurchased As String
			oNewNamePurchased = oPathPurchased & oName & oType

			'MessageBox.Show(oNewNamePurchased, "Generated filepath")
			oDoc.SaveAs(oNewNamePurchased, False)
		End If
		
		'If filename does not begin with V- then save to the correct production folder
		If oFolder1 <> "V-" Then
			'Grab first 4 characters of filename and then drop first 2, keeping 3rd and 4th
			oFolder2a = Left(oName, + 4)
			oFolder2 = Right(oFolder2a, + 2)
		
			Dim oPath As String
			oPath = "C:\Vault-Local\Designs\" & oFolder1 & "\" & oFolder2 & "\"

			Dim oNewName As String
			oNewName = oPath & oName & oType

			'MessageBox.Show(oNewName, "Generated filepath")
			oDoc.SaveAs(oNewName, False)
		End If

		'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)
		'.ShowSave()

		'catch an empty string in the imput
		If Err.Number <> 0 Then
			MessageBox.Show("No File Saved.", "iLogic: Dialog Canceled")
			'ElseIf oFileDlg.FileName <> "" Then 

			'save the file
			'oDoc.SaveAs(oPath, Filename, True) 'True = Save As Copy & False = Save As
		End If
		Else
		'If document has been saved before...
		Return
	End If
End If

Regards,

Autodesk Software: Inventor Professional 2018 | Vault Professional 2018 | Autocad Mechanical 2018
Programming Skills: Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Dimension Component! | Partlist Export! | Derive I-properties! | Vault Prompts Via API! | Vault Handbook/Manual!
Drawing Toggle Sheets! | Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 3 of 5

corym
Advocate
Advocate

It still fails with the following error.corym-2018-0244.pngcorym-2018-0245.png

Cory McConnell
0 Likes
Message 4 of 5

MjDeck
Autodesk
Autodesk
Accepted solution

There is a problem in Inventor 2019. Thanks for finding this. We should be able to fix it soon.
The statements
               Case kPartDocumentObject:     oType = ".ipt"
               Case kAssemblyDocumentObject: oType = ".iam"
               Case kDrawingDocumentObject:  oType = ".idw"

are showing the issue.

To work around it, please add the statement:

Imports Inventor.DocumentTypeEnum

to the top of the rule.


Mike Deck
Software Developer
Autodesk, Inc.

0 Likes
Message 5 of 5

MjDeck
Autodesk
Autodesk

The internal number for this issue is INVGEN-16747.


Mike Deck
Software Developer
Autodesk, Inc.

0 Likes