Grasshopper

algorithmic modeling for Rhino

C#: Output Parameter Index[i] too high or too low for Component X

Hi guys,

I have been struggling with the following error message: "Output Parameter Index[1] too high or too low for Component X" which repeats for every item of the string array. This happens at the following lines which are within the SolveInstance(IGH_DataAccess DA) method:

  for (var i = 0; i < m_settings.Length; i++)
                        {
                            DA.SetData(i, m_settings[i]);

                        }


I have also tried DA.SetDataList(i, m_settings[i]); but it created a new line for every character of the m_settings string variable instead of one for each item of the array.

What is going on?

Many thanks in advance!

Views: 867

Replies to This Discussion

Ok I solved this issue by revisiting the way the strings are split. I guess SolveInstance is already looping so the loop within loop is not working:

    string m_settings_temp;
                string[] m_settings;
                public void ShowSettingsGui()
                {
                    var dialog = new OpenFileDialog { Filter = "Data Sources (*.ini)|*.ini*|All Files|*.*" };
                    if (dialog.ShowDialog() != DialogResult.OK) return;

                    m_settings_temp = File.ReadAllText(dialog.FileName);
                    m_settings = m_settings_temp.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);
                    ExpireSolution(true);
                }



                protected override void SolveInstance(IGH_DataAccess DA)
                {
                    if (m_settings == null)
                    {
                        AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "You must declare some valid settings");
                        return;
                    }

                    else

                    {  
                            DA.SetDataList(0, m_settings);
                    }  
                   
                }

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service