RemoveAt_Example.gh (4.7 KB)
I’m trying to learn C# for Grasshopper, and falling at one of the first hurdles. I’m hoping someone can help.
I have a list of point (input as a list of Point3d), I’m simply trying to remove the last item in the list if the list count is odd.
When I try running the code below I get the error:
Error (CS0029): Cannot implicitly convert type void
to System.Collections.Generic.List<Rhino.Geometry.Point3d>
What am I doing wrong?
private void RunScript(List<Point3d> iPts, ref object A)
{
int cPtsCount = iPts.Count;
int cMod = cPtsCount % 2;
List<Point3d> cPoints = new List<Point3d>(iPts);
List <Point3d> oPoints = new List<Point3d>();
if (cMod == 1) {
oPoints = cPoints.RemoveAt(cPtsCount - 1);
}
else
{
oPoints = cPoints;
}
A = oPoints;
}