Grasshopper

algorithmic modeling for Rhino

Hey Guys,

 List<Point3d> pts = default(List<Point3d>);

if (!DA.GetDataList(0, pts)) { return; }

can only be called with a constructed list....   how might i construct this list properly?  Ive tried a few ways..


thanks

Views: 628

Replies to This Discussion

List<Point3d> pts = new List<Point3d>();

the default keyword in C# assigns the simplest value to any type. In the case of value types (classes) that is always null. In VB, there is no need for a default keyword as assignment with Nothing acts in the same way:

Dim pts As List(Of Point3d) = Nothing
Dim val As Int32 = Nothing


the above is equivalent with:

List<Point3d> pts = null;
int val = 0;


or, indeed

List<Point3d> pts = default(List<Point3d>);
int val = default(int);


--
David Rutten
david@mcneel.com
Poprad, Slovakia
sorry david,

there is something im obviously im not understanding here

I dim the variable for input the same way as you have dimmed it above.

System.Collections.Generic.List(<)Rhino.Geometry.Point3d(>) pts = new System.Collections.Generic.List(<)Rhino.Geometry.Point3d(>)();

(dont mind the brackets around the <'s, i just cant get it to stay in this comment)

and then I retrieve the data:

if (!DA.GetDataList(0, pts)) { return; }


Im getting the message:

You cannot call IGH_DataAccess.GetDataList on an item parameter, you have to call GetData instead..

if i call get data, the project will not build.

thanks david
Hi Brendon,

when you declare the inputs inside the RegisterInputParams function, you have to decide whether you want the parameter to be of type item, list or tree. Clearly you've picked item (the default), which means you can only call DA.GetData().

Change the parameter type to list instead and you're off:

pManager.Register_PointParam("Vertices", "V", "Curve control points", GH_ParamAccess.list);

--
David Rutten
david@mcneel.com
Poprad, Slovakia

ps. in order to get proper brackets into these posts you have to write them as character entities. Very annoying I know.
aha,

thanks david.

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service