Grasshopper

algorithmic modeling for Rhino

Hi all,

I have a basic problem with using lists in programming components. I try to make a component with one string input and one list string output. That is the result:

.....

        protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
        {
            pManager.AddTextParameter("stringInput", "stringInput", "stringInput", GH_ParamAccess.item);
        }

        protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)
        {
            pManager.AddTextParameter("stringOut", "stringOut", "stringOut", GH_ParamAccess.list);
        }

        protected override void SolveInstance(IGH_DataAccess DA)
        {
            string txt = null;

            if (!DA.GetData(0, ref txt)) { return; }

            List<string> list = new List<string>();
            for (int i = 0; i < 20; i++)
            {
                list.Add(txt);
            }


            DA.SetData(0, list);

        }

.....

I was kind of hoping that the output is (0;0) Test Test Test.....

what´s wrong ? :-)

thanks, pidi

Views: 304

Replies to This Discussion

This is what you did:

SetData(Int32, Object) 

Stores data in an output parameter during GH_Component.SolveInstance(). Use this function only for setting individual data items. If you want to set lists of data, you *must* call SetDataList() instead.

This is what you should do:

SetDataList(Int32, IEnumerable)

Stores a list of data in an output parameter during GH_Component.SolveInstance().

SetDataList(String, IEnumerable)

Stores data in an output parameter during GH_Component.SolveInstance().

SetDataList(Int32, IEnumerable, Int32)

Expert user function. Stores a list of data in an output parameter during GH_Component.SolveInstance(). 

Thanks a lot! and sorry for the stupid question. It works.

danke, pidi

gerne, des passt scho...am Anfang is es immer so ;-)

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service