Hi, I would like to let the user select a string value within a list. It works with the example bau whan I change the list values it does not work anymore!
Instead of :
Dim listValues As String() = New String() {“Item0”, “Item1”, “Item2”, “Item3”, “Item4”}
I’d like to use this:
Dim listValues As String() = New String() {“utf-8”, “Windows-1252”, “utf-16”, “utf-32”}
CODE
Public Shared Function GetEncodingOptions(ByVal doc As Rhino.RhinoDoc) As System.Text.Encoding
' For this example we will use a GetPoint class, but all of the custom
' "Get" classes support command line options.
Dim gp As New Rhino.Input.Custom.GetOption()
gp.SetCommandPrompt("Select encoding format: ")
' set up the options
Dim listValues As String() = New String() {"Item0", "Item1", "Item2", "Item3", "Item4"}
MsgBox(listValues.Length)
Dim listIndex As Integer = 1
Dim opList As Integer = gp.AddOptionList("List", listValues, listIndex)
While True
Dim get_rc As Rhino.Input.GetResult = gp.[Get]()
If get_rc = Rhino.Input.GetResult.Option Then
Rhino.RhinoApp.WriteLine("Command line option values are")
Rhino.RhinoApp.WriteLine(" List = {0}", listValues(listIndex))
If gp.OptionIndex() = opList Then
listIndex = gp.[Option]().CurrentListOptionIndex
End If
Exit While
Else
Continue While
End If
End While
Dim MyEncoding As System.Text.Encoding = System.Text.Encoding.UTF8
Try
MyEncoding = System.Text.Encoding.GetEncoding(listValues(listIndex))
Catch ex As Exception
Rhino.RhinoApp.WriteLine("Encoding value Error")
End Try
Return MyEncoding
End Function