Curtis, close, very close. The code is not working however. Your code did allow me to input the Title and Part Number iProperties. Once entered, the code fails. These are the error messages that I get when running your code:
ERROR MESSAGE:
Error in rule: iLogic File Namer, in document: Part1
The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))
And ...
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)
My 'design intent' is to run this rule externally, be independent of Inventor file type, and also independent of whether Title and Part Number are filled or blank. Code to work on currently opened file, and save the current file, if possible.
Here's the code as entered in the iLogic Editor:
'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 value of currrent file name
oNewFileName = iProperties.Value("Summary", "Title") _
& " " & "(" & iProperties.Value("Project", "Part Number") & ")"
oDoc = ThisDoc.Document
'Save the file 'True = Save As Copy 'False = Save As
oDoc.SaveAs(oNewFileName, False)
'End of iLogic File Namer.iLogicVB Code
System Specs.: Windows 7 Pro, PDSU 2014, Vault Basic 2014 Client, Vault Basic 2014Server
BTW, I've enjoyed purchasing and reading all of your Master Autodesk Inventor Series. I'm sorry to report I was late in purchasing the 2014 Edition (July 2, 2013). I enjoyed the reading more than the purchasing. Tee hee!
How did you and the other major iLogic contributors learn this stuff? While your books do a good job of discussing the basics if iLogic, are there other sources you or other might recommend regarding writing iLogic code? If you had the time, I'd ask that you author "The iLogic Bible".
I highly recommend your web site for more information about using iLogic.
Again, thank you for your assistance in helping me with the iLogic code. It is appreciated!