Hi, I’m trying in vb.net have an option to select a bloc from another file, but my option list does not work, could you help?
This is what I did:
'Check the file exist:
Dim PathProfils As String = "C:\Users\...\Profiles.3dm"
If My.Computer.FileSystem.FileExists(PathProfils) = False Then
Return Result.Failure
End If
'Read the bloc list in the file:
Dim TpProfilNames As New ArrayList
RhinoApp.WriteLine("Lecture de la bibliotheque de profils")
Dim profils As Rhino.FileIO.File3dm
profils = Rhino.FileIO.File3dm.Read(PathProfils)
For i = 0 To profils.InstanceDefinitions.Count - 1
If profils.InstanceDefinitions.Item(i).Name.ToLower.Contains("cuto") Then
profils.InstanceDefinitions.Item(i).Name = profils.InstanceDefinitions.Item(i).Name.Replace(" ", "") 'remove spaces
TpProfilNames.Add(profils.InstanceDefinitions.Item(i).Name)
End If
Next
Dim ProfilNames(TpProfilNames.Count - 1) As String
For i = 0 To TpProfilNames.Count - 1
ProfilNames(i) = TpProfilNames(i)
RhinoApp.WriteLine(ProfilNames(i))
Next
'Select a point with an option to choose a bloc to the other file
Dim SelectedPoint As Rhino.Geometry.Point3d ' point d'insertion
Dim gp As New Rhino.Input.Custom.GetPoint
gp.SetCommandPrompt("Sélectionner point")
Dim boolOption As New Rhino.Input.Custom.OptionToggle(True, "Non", "Oui")
gp.AddOptionToggle("Inverser", boolOption)
Dim listIndex As Integer = 0
Dim opList As Integer = gp.AddOptionList("Découpe", ProfilNames, listIndex)
While True
Dim get_rc As Rhino.Input.GetResult = gp.Get()
If gp.CommandResult() <> Rhino.Commands.Result.Success Then
Return gp.CommandResult()
End If
If get_rc = Rhino.Input.GetResult.Point Then
Rhino.RhinoApp.WriteLine("Command line option values are")
Rhino.RhinoApp.WriteLine("Inverser = {0}", boolOption.CurrentValue)
Rhino.RhinoApp.WriteLine("Nom de la découpe = {0}", ProfilNames(listIndex))
SelectedPoint = gp.Point
ElseIf get_rc = Rhino.Input.GetResult.[Option] Then
If gp.OptionIndex() = opList Then
listIndex = gp.Option().CurrentListOptionIndex
End If
Continue While
End If
Exit While
End While