I have an iLogic rule that has the command:
iProperties.Value("Status", "Eng Approved Date" ) = Now
When it runs, the error appears:
Conversion from string "01/11/2011 11:00:00 AM" to type 'Double' is not valid.
How do you format the dates properly in iLogic to fill in date iProperty fields? It seems like the VB date format functions do not work.
Solved! Go to Solution.
Solved by MjDeck. Go to Solution.
The date format isn't the problem.
You have to use the exact same spelling as in the iProperties dialog:
iProperties.Value("Status", "Eng. Approved Date" ) = Now
We should probably loosen it up, and recognize different wording that is very close.
You just need to update the help files. I pasted that from the "iProperties Quick Reference "Inventor help. Thanks!
Do you mean find typos in the rule text?
You can use this statement:
Option Explicit On
at the top of the rule. That will force you to declare all local variables (Inventor parameters are declared automatically). That can help to reduce typos.
If you add that statement at the top, you have to declare all variables. So if you had:
height = 5.3
You would change it to:
Dim height As Double = 5.3
Then if you had a typo later in the code:
If (hieght > 5) Then
it would show up as a "variable not declared" error.
thanks for the reply, this is an example from the rule. It is supposed to renumber the border zones of a idw depending what sheet number and size you are on. It was working in 2011, not sure whats changed, its 16 A4 pages long, could that be a problem
If iProperties.Value("Custom", "SheetNo") =1 And ActiveSheet.Size="A3" Then
iProperties.Value("Custom", "Zone1") =1
iProperties.Value("Custom", "Zone2") =2
iProperties.Value("Custom", "Zone3") =3
iProperties.Value("Custom", "Zone4") =4
iProperties.Value("Custom", "Zone5") =5
iProperties.Value("Custom", "Zone6") =6
ElseIf iProperties.Value("Custom", "SheetNo") =2 And ActiveSheet.Size="A3" Then
iProperties.Value("Custom", "Zone1") =7
iProperties.Value("Custom", "Zone2") =8
iProperties.Value("Custom", "Zone3") =9
iProperties.Value("Custom", "Zone4") =10
iProperties.Value("Custom", "Zone5") =11
iProperties.Value("Custom", "Zone6") =12
Can you post the original Inventor 2011 of the drawing (and linked assemblies or parts if required)? Or if the original has proprietary information, maybe you can post a simplified version that works the same as far as the border zones are concerned?
Did you write the rule, or is it from somebody else?
You only posted a small sample of the rule, right? Can you post the complete rule, maybe as a text file?
If you click Control-A in the rule editor, it will select all text. Then you can cut and paste it to Notepad, save it, and attach the file here.
But the rule probably depends on something in the drawing. So the best thing would be to attach the drawing file (Inventor 2011 version) and any linked assembly and part files (maybe using Pack and Go).
It will work in Inventor 2012 if you add the line:
ActiveSheet.Sheet.Update
to the end of your Zones rule (after the End If).
What is the error you're getting? If there is a message, can you post it here?
On my system, it wasn't updating the text on the sheet border. But adding the Update line fixed it.
error message
Error in rule: Zones, in document: GM Drawing.idw
Conversion from string "-" to type 'Double' is not valid.
more info
System.InvalidCastException: Conversion from string "-" to type 'Double' is not valid. ---> System.FormatException: Input string was not in a correct format.
at Microsoft.VisualBasic.CompilerServices.Conversions.ParseDouble(String Value, NumberFormatInfo NumberFormat)
at Microsoft.VisualBasic.CompilerServices.Conversions.ToDouble(String Value, NumberFormatInfo NumberFormat)
--- End of inner exception stack trace ---
at Microsoft.VisualBasic.CompilerServices.Conversions.ToDouble(String Value, NumberFormatInfo NumberFormat)
at Microsoft.VisualBasic.CompilerServices.Operators.CompareObject2(Object Left, Object Right, Boolean TextCompare)
at Microsoft.VisualBasic.CompilerServices.Operators.CompareObjectEqual(Object Left, Object Right, Boolean TextCompare)
at LmiRuleScript.Main()
at Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly(Assembly assem)
at iLogic.RuleEvalContainer.ExecRuleEval(String execRule)
It looks like your SheetNo property is set to - (dash)
Your rule can only handle SheetNo as a number. What do you want to set the zone numbers to if SheetNo is a dash? To leave the zone numbers unchanged, add this line to the top of your rule:
If iProperties.Value("Custom", "SheetNo") = "-" Then Return
If this doesn't work, please send me the latest Inventor 2012 version of your drawing.
I have a simlilar issue with iLogic trying to retreive a date from an excel spreadsheet but it keeps returning the number and not as the date. How do I change the number back to the date?
I have the excel populating custom fields in the iProperties, all other work well but this is the only one that keeps defaulting the cell type from text to number everytime.
I try and change everything to text, even in the excel sheet but this always comes back to a number in the iproperties and displays the number.
Here is the line in the iLogic rule:
iProperties.Value("Custom", "REV_A/1_DATE") = GoExcel.CurrentRowValue("REV_A/1_DATE")
Do you have any suggestions on how I would rectify this problem?
Thanks
The function DateTime.FromOADate will get the date:
iProperties.Value("Custom", "REV_A/1_DATE") = DateTime.FromOADate(GoExcel.CurrentRowValue("REV_A/1_DATE"))