Using iLogic results in the following errors

Using iLogic results in the following errors

Anonymous
Not applicable
587 Views
1 Reply
Message 1 of 2

Using iLogic results in the following errors

Anonymous
Not applicable

Please refer t the following link to view the code:

 

http://forums.autodesk.com/t5/Autodesk-Inventor-Customization/Need-help-with-ilogic-File-Save-rule/m...

 

Error Message

 

Error in rule: iLogic File Namer, in document: Clip (V-00023).ipt

The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))

 

More Info

 

System.ArgumentException: The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))

at Microsoft.VisualBasic.CompilerServices.LateBinding.InternalLateCall(Object o, Type objType, String name, Object[] args, String[] paramnames, Boolean[] CopyBack, Boolean IgnoreReturn)

at LmiRuleScript.Main()

at Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly(Assembly assem)

at iLogic.RuleEvalContainer.ExecRuleEval(String execRule)

 

What's causing the error?  How do I go about fixing the iLogic code so that the code runs as designed?

 

I've reviewed the code for several hours on and off and can't figure out why the errors mentioned above are still getting genrated.

 

Any help would be appreciated!  Smiley Happy

0 Likes
588 Views
1 Reply
Reply (1)
Message 2 of 2

MegaJerk
Collaborator
Collaborator

So far, the code is fine, but you need to tell the file where to save, as well as an extension! 

Replacing your original SaveAs code with the following line should give you a workable example. 

oDoc.SaveAs("C:\MegaFolder\" & oNewFileName & ".ipt", False)

 
Depending on your use, you may also want to have a Case Statement that fills in the extension needed at the end, based on the type of document that is currently active. 

The following is a modification to the entire code block that you posted on the other thread : 

'check for blank iProperty
 
If iProperties.Value("Summary", "Title") = "" Then
 
'prompt user for info if iProperty is blank
oTitle = InputBox("Title info must be filled out before saving file!", _
"iLogic - Title", iProperties.Value("Summary", "Title"))
 
'check for empty input
'in case the user cancels out of the Input box
 
If oTitle = "" Then
Return 'end rule
Else
 
End If
 
'write user input to the iProperty
iProperties.Value("Summary", "Title") = oTitle
End If
 
'check for blank iProperty
If iProperties.Value("Project", "Part Number") = "" Then
 
'prompt user for info if iProperty is blank
oPartNumber = InputBox("Part Number must be filled out before saving file!", _
"iLogic - Part Number", iProperties.Value("Project", "Part Number"))
'check for empty input
'in case the user cancels out of the input box
If oPartNumber = "" Then
Return 'end rule
Else
 
End If
 
'write user input to the iProperty
iProperties.Value("Project", "Part Number") = oPartNumber
End If
 
'Set the Path the file will live at : 
Dim oPathName As String 
oPathName = "C:\MegaFolder\"

'Set value of currrent file name
oNewFileName =  iProperties.Value("Summary", "Title") _
& " " & "(" & iProperties.Value("Project", "Part Number") & ")"

'Get this active Document Object 
oDoc = ThisDoc.Document

'Find the Document Type
Dim oDocType As String

Select Case oDoc.DocumentType 
	Case kPartDocumentObject 
	oDocType = ".ipt"
	Case kAssemblyDocumentObject
	oDocType = ".iam"
	Case kDrawingDocumentObject 
	oDocType = ".idw"
	Case kPresentationDocumentObject
	oDocType = ".ipn"
	Case Else
	MessageBox.Show("Unknown Document Type!", "Document Type Error")
	Return
End Select 

 
'Save the file 'True = Save As Copy 'False = Save As
If System.IO.File.Exists(oPathName & oNewFileName & oDocType) = True Then 
	oDoc.Save()
	Else
	oDoc.SaveAs(oPathName & oNewFileName & oDocType, False)
End If 

'End of iLogic File Namer.iLogicVB Code

 

 

 I know that there are more file extensions than that, but this is simply a little outline of some things to consider when messing with saving files. 

The last thing that I would like to point out is that there are no checks being done to the text being input into the iProperty fields that eventually are being used to make up the file name of whatever it is you're saving. This could eventually lead to an error occurring simply due to a bad input on the user's part. If you feel like you need to compensate for that possibility, then you should do so! 

I hope that this helps. 

 





If my solution worked or helped you out, please don't forget to hit the kudos button 🙂
iLogicCode Injector: goo.gl/uTT1IB

GitHub
0 Likes