Quantcast
Channel: Scripting - McNeel Forum
Viewing all articles
Browse latest Browse all 4159

Sphere method in C#

$
0
0

Hi, I just started learning C# coding and I am trying to define a method that will create and grid of spheres but I get this error at the end:

Error (CS0029): Cannot implicitly convert type ‘Rhino.Geometry.Sphere’ to ‘System.Collections.Generic.List<Rhino.Geometry.Sphere>’ (line 77)

  private     List<Sphere> spheresList (int x, int y, double r)
  {
    int rows = 0;
    int columns = 0;
    double radius = 0;
    for (int i = 0;i < 200;  i = i + rows){
      for (int j = 0;j < 350; j = j + columns){
        Point3d myPoint = new Point3d(i, j, 0);
        Sphere mySphere = new Sphere(myPoint, radius);
        //spheresList.Add(mySphere);

        return mySphere;
      }
    }
  }

So should I convert the type? If so, how? I attach the gh file so you can see the error.

methodSphere.gh (6.5 KB)

5 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 4159