Inventor Customization

Inventor Customization

Reply
Contributor
voutilainen
Posts: 25
Registered: ‎05-10-2012
Message 1 of 23 (408 Views)
Accepted Solution

Autodesk 2013 iLogic issue with inputboxes

408 Views, 22 Replies
05-24-2012 11:43 PM

Hi everybody, this is my second topic upon that issue. The first  one was here: http://forums.autodesk.com/t5/Autodesk-Inventor/iLogic-inputbox-only-decimal-value-with-coma-not-wit...

 

To resume the issue here, my problem is that I did, a couple of months ago, a part with a rule containing some input boxes. It worked without a bug and set it as a specific template, on Inventor 2012.
I tried to reuse it as a template without changing its rule on Inventor 2013. When the input box pops out and ask the value it needs, if I type "0.2" it says that "string's conversion "0.2" in a 'double' type isn't valid". But if I type "0,2" I have absolutely no problems.

And on the "more infos"  tab, I can see that message:

"System.InvalidCastException: La conversion de la chaîne "0.2" en type 'Double' n'est pas valide. ---> System.FormatException: Le format de la chaîne d'entrée est incorrect.

   à Microsoft.VisualBasic.CompilerServices.Conversions.ParseDouble(String Value, NumberFormatInfo NumberFormat)

   à Microsoft.VisualBasic.CompilerServices.Conversions.ToDouble(String Value, NumberFormatInfo NumberFormat)

   --- Fin de la trace de la pile d'exception interne ---

   à Microsoft.VisualBasic.CompilerServices.Conversions.ToDouble(String Value, NumberFormatInfo NumberFormat)

   à LmiRuleScript.Main()

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

   à iLogic.RuleEvalContainer.ExecRuleEval(String execRule) "

 

 

I work on:

Windows 7

Autodesk design suite premium 2013 french.

 

I’m glad that you asked. Yes there is a way to change the entire document’s culture info. The reason I didn’t go that route before was because I didn’t know if you had some users that were going to be using the ‘,’ decimal point and some that may use the ‘.’ point. With that being said, the following example will show you how to set up a main culture across your entire document, as well as some other information that you may find useful. If you have any other questions about this code, or anything else related, feel free to ask. This has been a real learning experience! 

 

 

 

 

Imports System.Globalization
Imports System.Threading
Dim value, userInputString As String
Dim userInputDouble As Double
Dim InputBool As Boolean
Dim oNumber As Decimal
'Thread.CurrentThread.CurrentCulture = New CultureInfo("fr-FR") ''' French language culture!
Thread.CurrentThread.CurrentCulture = New CultureInfo("en-GB") ''' English language (with a UK twist!)
'Thread.CurrentThread.CurrentCulture = New CultureInfo("en-US") ''' English language (with a Southern Twang!)
'Thread.CurrentThread.CurrentCulture = New CultureInfo("de-DE") ''' German language from the Father Land!
'''/////////////////////////////////////////////////////////////////////////////////////////////////////
'''
''' Here are some culture codes '''
''' en-GB - (English - Great Britain)
''' en-US - (English - United States)
''' fr-FR - (French - France)
''' de-DE - (German - Germany)
'''
'''
''' Simply replace the above 'New CultureInfo("??-??") with one of the codes to change
''' how this document reacts.
'''
''' More culture codes can be found here :
'''
''' http://msdn.microsoft.com/en-us/library/System.globalization.cultureinfo(v=vs.71).aspx
'''
'''/////////////////////////////////////////////////////////////////////////////////////////////////////
'''
'''
'''/////////////////////////////////////////////////////////////////////////////////////////////////////
'''
''' In this comment section are some simple tests to see if your current culture is working
''' based on if the following value returns true or false.
'''
''' Uncomment the code section you'd like to test with, if you'd like to test.
''' Only uncomment *one*. Specifically the one pertaining to the culture that you've set.
'''
''' (Test for ENGLISH language culture. Should return true)
'''
''' value = "0.2"
'''
''' If IsNumeric(value) = True Then
''' Messagebox.Show("True","")
''' Else
''' MessageBox.Show("False","")
''' End If
'''
'''
''' (Test for NON-ENGLISH language culture. Should return true)
'''
''' value = "0,2"
'''
''' If IsNumeric(value) = True Then
''' Messagebox.Show("True","")
''' Else
''' MessageBox.Show("False","")
''' End If
'''
'''/////////////////////////////////////////////////////////////////////////////////////////////////////
InputBool = False
While InputBool = False
userInputString = InputBox("Please Enter a Number. Your Current Culture is set to : " _
& Thread.CurrentThread.CurrentCulture.Name, "Title", "")
If IsNumeric(userInputString) = True Then
InputBool = True
userInputDouble = CDbl(userInputString)
Else
InputBool = False
MessageBox.Show("The number you entered - " & userInputString & _
" - was not recognized as valid. Please try again.","")
End If
End While
MessageBox.Show("Your input, multiplied by 2 = " & userInputDouble * 2, "Result") 

 

 

 

Valued Mentor
MegaJerk
Posts: 278
Registered: ‎01-26-2011
Message 2 of 23 (403 Views)

Re: Autodesk 2013 iLogic issue with inputboxes

05-25-2012 05:36 AM in reply to: voutilainen

Does the code below error out for you, when you type in 0.2 ? 

 

 

Dim iString As String
Dim iDoub As Double

'''/////////// Let's ask the user to type something in 

iString = InputBox("Super String Converter-o-Matic 2012", "Strings --> Doubles!", "") 

'''/////////// If the input can be succesfully considered a number, then we proceed
If IsNumeric(iString) = True Then

'''/////////// If it is a number, we'll set our variable 'iDoub' to equal the String, converted over
'''/////////// into a double

iDoub = CDbl(iString)

'''/////////// Now we show you the result

MessageBox.Show("Your Double Is :  " & iDoub, "Converted!") 

Else 

'''/////////// If the variable 'iString' can't be considered to have a numeric value, then we
'''/////////// tell the user that we can't convert their input

MessageBox.Show("We can't convert letters to numbers! We have standards!", "Not-Converted!") 

End If 

 

--------------------------------------------------------------------------------------

If my solution seems to remedy your problem, please press the Accept Solution button, -
as it increases my power levels and will eventually help to elevate me towards outer space.

Check out my iLogic injection tool here : http://goo.gl/ce1Qg
--------------------------------------------------------------------------------------
Contributor
voutilainen
Posts: 25
Registered: ‎05-10-2012
Message 3 of 23 (381 Views)

Re: Autodesk 2013 iLogic issue with inputboxes

05-28-2012 10:54 PM in reply to: MegaJerk

Hi Megajerk, Thanks for your answer.

 

So It doesn't error me out, it says your message "We can't convert letters to numbers! We have standards!"

 

Makes me smile.

 

So  must I apply it to my code?

Valued Mentor
MegaJerk
Posts: 278
Registered: ‎01-26-2011
Message 4 of 23 (372 Views)

Re: Autodesk 2013 iLogic issue with inputboxes

05-29-2012 05:45 AM in reply to: voutilainen

Actually, if you're getting that message when  you type in 0.2 (zero point two), then there certainly is something wrong. 

 

Try the following code and tell me the values that it returns back to you in the final box. 

 

Dim oBlah,oLaLa As String
Dim oDarn As Char
oBlah = InputBox("Input your string", "String Detective", "")

For Each oDarn In oBlah 
	If oLaLa = "" Then 
		oLaLa = (Asc(oDarn))
		Else
		oLaLa = oLaLa & "," &  (Asc(oDarn))
	End If 
Next 

MessageBox.Show(oLaLa,"String Detective Has Found This!") 

 

So when you run that code, type in your 0.2, and tell me what three numbers you get back. 

 

 

--------------------------------------------------------------------------------------

If my solution seems to remedy your problem, please press the Accept Solution button, -
as it increases my power levels and will eventually help to elevate me towards outer space.

Check out my iLogic injection tool here : http://goo.gl/ce1Qg
--------------------------------------------------------------------------------------
Contributor
voutilainen
Posts: 25
Registered: ‎05-10-2012
Message 5 of 23 (369 Views)

Re: Autodesk 2013 iLogic issue with inputboxes

05-29-2012 10:34 PM in reply to: MegaJerk

So the answer is: 48,46,50

Valued Mentor
MegaJerk
Posts: 278
Registered: ‎01-26-2011
Message 6 of 23 (363 Views)

Re: Autodesk 2013 iLogic issue with inputboxes

05-30-2012 05:04 AM in reply to: voutilainen

Well that’s what you should be getting. You may have a rather unique problem on your hand being that you’re input of 0.2 is producing the correct Ascii values (48,46,50), but the function ‘IsNumeric’ is refusing to accept that as a proper numeric value (despite the fact that it is). 

Perhaps someone from Autodesk would be willing to dig deeper into this. Perhaps it’s a localization bug.

I’m sorry that I couldn’t be more useful.  

--------------------------------------------------------------------------------------

If my solution seems to remedy your problem, please press the Accept Solution button, -
as it increases my power levels and will eventually help to elevate me towards outer space.

Check out my iLogic injection tool here : http://goo.gl/ce1Qg
--------------------------------------------------------------------------------------
Contributor
voutilainen
Posts: 25
Registered: ‎05-10-2012
Message 7 of 23 (357 Views)

Re: Autodesk 2013 iLogic issue with inputboxes

05-30-2012 10:36 PM in reply to: MegaJerk

No problem, thanks for your time and help!

Contributor
voutilainen
Posts: 25
Registered: ‎05-10-2012
Message 8 of 23 (329 Views)

Re: Autodesk 2013 iLogic issue with inputboxes

06-06-2012 10:41 PM in reply to: voutilainen

Hi again everybody, after looking a bit more on the web, it seems that this issue is not related to inventor, but to visual basic. Some people have the same kind of problem, but on other software. But I'm searching, and nobody seems to have a real solution. Could someone help me?

Valued Mentor
MegaJerk
Posts: 278
Registered: ‎01-26-2011
Message 9 of 23 (324 Views)

Re: Autodesk 2013 iLogic issue with inputboxes

06-07-2012 05:13 AM in reply to: voutilainen

Does the following code give you the "Unable to parse" or does it return a message box with the correct numerical value in it? 

Dim value As String
Dim result As Decimal 

value = "0.2"

If Decimal.TryParse(value, result)
   MessageBox.Show(result)
Else
   MessageBox.Show("Unable to parse:  " & value,"")   
End If

 

 

(That is for ilogic) 

 

--------------------------------------------------------------------------------------

If my solution seems to remedy your problem, please press the Accept Solution button, -
as it increases my power levels and will eventually help to elevate me towards outer space.

Check out my iLogic injection tool here : http://goo.gl/ce1Qg
--------------------------------------------------------------------------------------
Contributor
voutilainen
Posts: 25
Registered: ‎05-10-2012
Message 10 of 23 (318 Views)

Re: Autodesk 2013 iLogic issue with inputboxes

06-07-2012 10:34 PM in reply to: MegaJerk

Unable to parse.

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are You Going To Be @ AU 2014? Feel free to drop by our AU topic post and share your plans, plug a class that you're teaching, or simply check out who else from the community might be in attendance. Ohh and don't forgot to stop by the Autodesk Help | Learn | Collaborate booths in the Exhibit Hall and meet our community team if you get a chance!