Community
Inventor Forum
Welcome to Autodesk’s Inventor Forums. Share your knowledge, ask questions, and explore popular Inventor topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

iLogic to set iProperty date

19 REPLIES 19
SOLVED
Reply
Message 1 of 20
Anonymous
4420 Views, 19 Replies

iLogic to set iProperty date

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.

19 REPLIES 19
Message 2 of 20
MjDeck
in reply to: Anonymous

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.


Mike Deck
Software Developer
Autodesk, Inc.

Message 3 of 20
Anonymous
in reply to: MjDeck

You just need to update the help files. I pasted that from the "iProperties Quick Reference "Inventor help. Thanks!

Message 4 of 20
stephengibson76
in reply to: MjDeck

is there a way to find which text in a rule does not match?

Stephen Gibson



View stephen gibson's profile on LinkedIn


Message 5 of 20
MjDeck
in reply to: stephengibson76

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.

 

 


Mike Deck
Software Developer
Autodesk, Inc.

Message 6 of 20
stephengibson76
in reply to: MjDeck

thanks, how does that help me find mistakes already in the rule?

Stephen Gibson



View stephen gibson's profile on LinkedIn


Message 7 of 20
MjDeck
in reply to: stephengibson76

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.

 

 


Mike Deck
Software Developer
Autodesk, Inc.

Message 8 of 20
stephengibson76
in reply to: MjDeck

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
Stephen Gibson



View stephen gibson's profile on LinkedIn


Message 9 of 20
MjDeck
in reply to: stephengibson76

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?

 


Mike Deck
Software Developer
Autodesk, Inc.

Message 10 of 20
stephengibson76
in reply to: MjDeck

this is the 2011 version

Stephen Gibson



View stephen gibson's profile on LinkedIn


Message 11 of 20
MjDeck
in reply to: stephengibson76

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).

 


Mike Deck
Software Developer
Autodesk, Inc.

Message 12 of 20
stephengibson76
in reply to: MjDeck

sorry, i thought I attached it last time

Stephen Gibson



View stephen gibson's profile on LinkedIn


Message 13 of 20
MjDeck
in reply to: stephengibson76

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).

 


Mike Deck
Software Developer
Autodesk, Inc.

Message 14 of 20
stephengibson76
in reply to: MjDeck

thanks but I am still getting the same error

Stephen Gibson



View stephen gibson's profile on LinkedIn


Message 15 of 20
MjDeck
in reply to: stephengibson76

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.


Mike Deck
Software Developer
Autodesk, Inc.

Message 16 of 20
stephengibson76
in reply to: MjDeck

error message

 

 

Error in rule: Zones, in document: GM Drawing.idw
Conversion from string "-" to type 'Double' is not valid.

 

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)

 

Stephen Gibson



View stephen gibson's profile on LinkedIn


Message 17 of 20
MjDeck
in reply to: stephengibson76

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.


Mike Deck
Software Developer
Autodesk, Inc.

Message 18 of 20
stephengibson76
in reply to: MjDeck

doh...

 

thankyou very much for your help

Stephen Gibson



View stephen gibson's profile on LinkedIn


Message 19 of 20
hardingster
in reply to: MjDeck

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

Message 20 of 20
MjDeck
in reply to: hardingster

The function DateTime.FromOADate will get the date:

iProperties.Value("Custom", "REV_A/1_DATE") =  DateTime.FromOADate(GoExcel.CurrentRowValue("REV_A/1_DATE"))

 


Mike Deck
Software Developer
Autodesk, Inc.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report