• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    Autodesk Inventor Customization

    Reply
    Mentor
    MegaJerk
    Posts: 188
    Registered: ‎01-26-2011

    Re: Autodesk 2013 iLogic issue with inputboxes

    06-08-2012 10:03 AM in reply to: voutilainen

    I just couldn’t stop thinking about this. I feel that I might have cracked it finally. Here is some ilogic code that will force it to try in both French and UK English localizations. This should allow for either  a comma or a decimal point for string input. You can of course set it to only do or the other using further logic, but I think that this should get us on the correct track… or at least I hope. Tell me the results of the following code.

     

    Imports System.Globalization
    
    Dim value As String
    Dim style As NumberStyles
    Dim FRculture, UKculture As CultureInfo
    Dim oNumber As Decimal
    
    ' Parse currency value using en-GB culture.
    value = "0.2"
    style = NumberStyles.AllowDecimalPoint  Or NumberStyles.AllowCurrencySymbol
    
    'culture = CultureInfo.CreateSpecificCulture("en-GB")
    'USculture = CultureInfo.CreateSpecificCulture("en-US")
    
    FRculture = CultureInfo.CreateSpecificCulture("fr-FR")
    UKculture = CultureInfo.CreateSpecificCulture("en-UK")
    
    If Decimal.TryParse(value, style, FRculture, oNumber) = True Or Decimal.TryParse(value, style, UKculture, oNumber) = True  Then
       MessageBox.Show("Converted : "& value & " --> To --> " &  oNumber,"")
    Else
       MessageBox.Show("Unable to convert : "& value, "")
    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
    --------------------------------------------------------------------------------------
    Please use plain text.
    Contributor
    Posts: 23
    Registered: ‎05-10-2012

    Re: Autodesk 2013 iLogic issue with inputboxes

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

    I really appreciate your work about this.

    So, the answer is that 0.2 has been converted to 0,2!

    Thank you so much! But now I'm not sure to understand which part of your code I must re-use in mine, and if y must do it everytime I need to enter a value (but I guess that yes, i must.)

    Please use plain text.
    Mentor
    MegaJerk
    Posts: 188
    Registered: ‎01-26-2011

    Re: Autodesk 2013 iLogic issue with inputboxes

    06-11-2012 02:12 PM in reply to: MegaJerk

    I couldn't work on a better response during work hours, but I did manage to make this code to give you an example of a way you could implement this. I will write something better tomorrow. Sorry :smileyvery-happy: 

     

    'Your Imports would be first.
    Imports System.Globalization
    
    
    Sub Main ()
    'All of your main code would go here, right under the Sub Main()
    
    Dim UserInput As String 
    Dim oNumber As Decimal 
    
    UserInput = InputBox("Please Enter A Number", "ACME Number Machine", "")
    
    	If UserInput <> "" Then 
    	oNumber = NumberMuncherUK(UserInput)
    	MessageBox.Show(oNumber,"") 
    	Else 
    	MessageBox.Show("Blank Entry","Error") 
    	End If 
    	
    End Sub 
    
    
    
    Function NumberMuncherUK (IncString As String) As Decimal 
    
    	Dim RetVal As Decimal
    	Dim style As NumberStyles
    	Dim UKculture As CultureInfo
    	'Dim  FRculture As CultureInfo
    	'FRculture = CultureInfo.CreateSpecificCulture("fr-FR")
    	
    	style = NumberStyles.AllowDecimalPoint  	
    	UKculture = CultureInfo.CreateSpecificCulture("en-UK")
    	
    		If Decimal.TryParse(IncString, style, UKculture, RetVal) = False 
    			RetVal = -1.0
    		End If 
    		
    	Return RetVal
    	
    End Function

     

     Basically you would just call that function every time you wanted to see if the user input a correct value before passing it along. It returns a -1 (or whatever value you would like) so that you can use that in your logic down the road. 

    If UserInput = -1 Then
    MessageBox.Show("You input a silly number!","")

    End If

     

    So on and so forth.  

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

    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
    --------------------------------------------------------------------------------------
    Please use plain text.
    Contributor
    Posts: 23
    Registered: ‎05-10-2012

    Re: Autodesk 2013 iLogic issue with inputboxes

    06-11-2012 11:09 PM in reply to: MegaJerk

    Okay, thanks a lot.

    I'm not sure to fully understand so I tried to do use this like this:

    Imports System.Globalization
    
    
    Sub Main ()
    			Dim Module As String 
    			Dim oModule As Decimal
    
    		Module = InputBox("Entrez le module du pignon:","NIHS 20-02","")
    		
    
    	If Module <> "" Then 
    	oModule = NumberMuncherUK(Module)
    	End If 
    
    	
    	Dtete=oModule*(25+1.44)
    	Dprimitif=oModule*25
    	Dfond=oModule*(25-3.5)
    	Epaisseur_s=1.41*oModule
    	Rogive=0.8*1.44*oModule
    	Distance_t=Rogive-(Epaisseur_s/2)
    	
    	
    	
    End Sub 
    
    
    
    Function NumberMuncherUK (IncString As String) As Decimal 
    
    	Dim RetVal As Decimal
    	Dim style As NumberStyles
    	Dim UKculture As CultureInfo
    	'Dim  FRculture As CultureInfo
    	'FRculture = CultureInfo.CreateSpecificCulture("fr-FR")
    	
    	style = NumberStyles.AllowDecimalPoint  	
    	UKculture = CultureInfo.CreateSpecificCulture("en-UK")
    	
    		If Decimal.TryParse(IncString, style, UKculture, RetVal) = False 
    			RetVal = -1.0
    		End If 
    		
    	Return RetVal
    	
    End Function
    
    
    

     

    But when it is compilating, it says that: "Value" isn't a member of "String".

    Please use plain text.
    Mentor
    MegaJerk
    Posts: 188
    Registered: ‎01-26-2011

    Re: Autodesk 2013 iLogic issue with inputboxes

    06-12-2012 05:23 AM in reply to: voutilainen

    Actually, there are a few problems. You are using a dim called “Module” which is a reserved keyword in VB.net, and is the reason it turns up as a red color. I have rewritten your code, and it is working on my machine, but you will of course need to test it on yours. Notice how I also moved the calculations that are based on the user input to under the ‘If uModule <> "" Then’ ?  That’s so that they don’t calculate using user input that hasn’t passed the condition check (the condition check in this case being the user input field being left empty or not).

    Let’s see if the following will work correctly on your machine. 

     

     

    Imports System.Globalization


    Sub Main ()

    Dim uModule As String
    Dim oModule As Decimal

    uModule = InputBox("Entrez le module du pignon:","NIHS 20-02","")


    If uModule <> "" Then
    oModule = NumberMuncherUK(uModule)

    If oModule <> -1 Then
    Dtete=oModule*(25+1.44)
    Dprimitif=oModule*25
    Dfond=oModule*(25-3.5)
    Epaisseur_s=1.41*oModule
    Rogive=0.8*1.44*oModule
    Distance_t=Rogive-(Epaisseur_s/2)
    MessageBox.Show(DTete & " - " & Dprimitif & " - " & Dfond & " - " & Epaisseur_s & " - " & Rogive & " - " & Distance_t, "")
    Else
    MessageBox.Show("There has been a conversion problem from string to Decimal. Please Try Again.","")
    End If

    Else
    MessageBox.Show("You've left the input blank. Please start over.", "Blank Input Error")
    End If




    End Sub



    Function NumberMuncherUK (IncString As String) As Decimal

    Dim RetVal As Decimal
    Dim style As NumberStyles
    Dim UKculture As CultureInfo
    'Dim FRculture As CultureInfo
    'FRculture = CultureInfo.CreateSpecificCulture("fr-FR")

    style = NumberStyles.AllowDecimalPoint
    UKculture = CultureInfo.CreateSpecificCulture("en-UK")

    If Decimal.TryParse(IncString, style, UKculture, RetVal) = False
    RetVal = -1.0
    End If

    Return RetVal



    End Function

     

     

    I should also say that the only option in my ilogic editor that is checked is Silent Operation. I would suggest making sure you don’t have Straight VB code checked. 

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

    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
    --------------------------------------------------------------------------------------
    Please use plain text.
    Contributor
    Posts: 23
    Registered: ‎05-10-2012

    Re: Autodesk 2013 iLogic issue with inputboxes

    06-13-2012 12:12 AM in reply to: MegaJerk

    So I try it at on my machine.

     

    And I managed to make it work! Thank you!

    I just need now to do it on every value! Thank you once again!

    Please use plain text.
    Mentor
    MegaJerk
    Posts: 188
    Registered: ‎01-26-2011

    Re: Autodesk 2013 iLogic issue with inputboxes

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

    That’s just great! In the spirit of uncovering more information about how this problem came about, I wanted to ask you a few questions. Which version of Inventor were you using before you had this localization problem? Was it localized in French, or was it an English language package? Was your computer set up with a different localization for the past / present Inventor installation, or has it always been set to French language?

    If it seems that everything stayed the same, and only the Inventor version (from 2012 to 2013) made the difference, then they’ve changed how they calculate things based on the language culture, which would be righteous information to have if someone out there in developer land started to work on a plug-in / iLogic code that could potentially be used internationally.  
     

    Any who, thanks for your time! Continue to post in the customization forums if any other problems (or neat discoveries) arise.

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

    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
    --------------------------------------------------------------------------------------
    Please use plain text.
    Contributor
    Posts: 23
    Registered: ‎05-10-2012

    Re: Autodesk 2013 iLogic issue with inputboxes

    06-13-2012 10:49 PM in reply to: MegaJerk

    The version before was only Inventor 2012 in French. Nothings changed about it. I just have uninstalled the old one and install the new version. But if you remember, I have said that, checking on google, some people have the same issue, same error, with visual basic editors like iLogic on inventor, but on other software. So I'm wondering if it could be something with an update of windows 7 (I always had windows 7, but sometimes updates create some bugs here, I don't know).

     

    I'm just wondering that in your code, you used "Style = NumberStyles.AllowDecimalPoint" . Don't you know if it's possible, at some point, to use this in the begining of the code to make it apply for every value next, automatically? Sorry, as I said, I'm not familiar with programmation, I'm learning by doing simple stuff.

    Please use plain text.
    Mentor
    MegaJerk
    Posts: 188
    Registered: ‎01-26-2011

    Re: Autodesk 2013 iLogic issue with inputboxes

    06-14-2012 06:40 AM in reply to: MegaJerk

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

     

     

     

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

    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
    --------------------------------------------------------------------------------------
    Please use plain text.
    Mentor
    MegaJerk
    Posts: 188
    Registered: ‎01-26-2011

    Re: Autodesk 2013 iLogic issue with inputboxes

    06-14-2012 08:00 AM in reply to: MegaJerk

    I should note that there was a small error in my last code posts. I called out the culture info as “en-UK” when it should have been “en-GB” for English-Great Britain.  Oops. 

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

    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
    --------------------------------------------------------------------------------------
    Please use plain text.