[C#]Problem in Create custom grid of point

I'm studying the cellular automaton model. And first to Create custom grid of point. I took a vb code as a reference. But the c# code i made was error with the message that "Rhino.Geometry.Plane doesn't contain a definition for xaxis/yaxis/original". 

There is also some wrong in the code of making the generation cellular.

Here is the code and the ghx file. Are there some can give a help. Thanks.

***********code****************

private void RunScript(Plane Plane, int XNum, int YNum, double Dis, ref object PointsGrid) 

 {  

//Create 2 dimentional list of points

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

    Vector3d x_dir = new Vector3d(Plane.xaxis);

    x_dir = x_dir * Dis;
    Vector3d y_dir = new Vector3d(Plane.yaxis);

    y_dir = y_dir * Dis;
    Point3d Base = new Point3d(Plane.origin);

    int i = 0;

    int j = 0;
    for (i = 0; i <= XNum; i++) {

      for (j = 0; j <= YNum; j++) {

        Point3d newPt = new Point3d(Base);

        Vector3d V1 = new Vector3d(x_dir);

        V1 = V1 * i;

        Vector3d V2 = new Vector3d(y_dir);

        V2 = V2 * j;

        newPt = newPt + V1 + V2;

        Points.Add(newPt);

  }

***********code****************

  • up

    Taehyuk Kwak

     

     

     

     

    private void RunScript(Plane Plane, int XNum, int YNum, double Dis, ref object PointsGrid) 

     {  

    //Create 2 dimentional list of points

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

        Vector3d x_dir = new Vector3d(Plane.XAxis);

        x_dir = x_dir * Dis;
        Vector3d y_dir = new Vector3d(Plane.YAxis);

        y_dir = y_dir * Dis;
        Point3d Base = new Point3d(Plane.Origin);

        int i = 0;

        int j = 0;
        for (i = 0; i <= XNum; i++) {

          for (j = 0; j <= YNum; j++) {

            Point3d newPt = new Point3d(Base);

            Vector3d V1 = new Vector3d(x_dir);

            V1 = V1 * i;

            Vector3d V2 = new Vector3d(y_dir);

            V2 = V2 * j;

            newPt = newPt + V1 + V2;

            Points.Add(newPt);

      }

     

    C# is case-sensitive

     

    xaxis -> XAxis

    yaxis -> YAxis

    origin -> Origin

    1
    • up

      ZHAO Wenbiao

      Thanks for you two to give the solution.

      I wondered where you can get the information about C# explanation or help specific for grasshopper.

      I got it from the file "RhinoDotNetDocs.chm". In that file, the OnPlane(openNURBS) Property is xaxis/yaxis which i s lower-case (OnPlane::xaxis ).

      I often confuse about the library/function/class/definition used in grasshopper. Where can I get these ?

       

      And another, after the grid, I coded the mechanism of cellular automaton by a reference from vb code.

      But it didn't work and showed four Errors as followed:

      1.Cannot implicitly convert type 'Rhino.Geometry.Point3d' to 'Rhino.Geometry.Point3d[*,*]'

      2.'Grid' is a 'variable' but is used like a 'method'

      3.'System.Collection.Generic.List<Rhino.Geometry.Point3d>.Count' is a 'property' but is used like a 'method'

      4.System.Collection.Generic.List<intd>.Count' is a 'property' but is used like a 'method'

      I am a new learner, i don't know how to solve and correct this error.

      I appreciate you help. Thank a lot.

      The ghx file is attached.

      1
      • up

        ZHAO Wenbiao

        Thanks for you help.
        And it's solved at all after correcting the 'Point.count()' and 'State.count()' to 'Point.count' and 'State.count'.