C# Export List Of Points

In VisualStudio:

pManager.AddPointParameter("attractors", "outputlist", "intial attractors", GH_ParamAccess.list);


         public Point3dList uvGrid(int u, int v, Surface S)
            {
                List<Point3d> uvGrid = new List<Point3d>();
                List<Rhino.Geometry.Point3d> uvGrid = new List<Point3d>();
                for (int i = 0; i < u + 1; i++)
                {
                    for (int j = 0; j < v + 1; j++)
                    {
                        Point3d srfPt = S.PointAt(S.Domain(0).Length / u * i, S.Domain(1).Length / v * j);
                        uvGrid.Add(srfPt);
                    }
                }
                return uvGrid;
            }

I found the answer before, but I can’t find it. Any ideas?

Also DA.SetDataList is also set correctly.

So what is the question? Please be specific - thanks.

– Dale

As written the function draws an error when outputting a 3d pointlist, what is the correct way to iterate(forloop), create a list of point3d’s in a function, and then assign them to an output?

Well, a Point3dList object is not a a generic list of Point3d structs (List).

So how about this?

public Point3d[] uvGrid(int u, int v, Surface S)
{
  var grid = new List<Point3d>();
  for (var i = 0; i < u + 1; i++)
  {
    for (var j = 0; j < v + 1; j++)
    {
      var srfPt = S.PointAt(S.Domain(0).Length / u * i, S.Domain(1).Length / v * j);
      grid.Add(srfPt);
    }
  }
  return grid.ToArray();
}

— Dale