Hi, i need help with an error i get in code for a grasshopper code i am writing in VS. C# code

I recently started building a code in vs for grasshopper comp, and i got it working mostly i just have this one issue with error CS1061, i cant seem to find the problem in the code and solve it. I am a newbie still, maybe its some dumb mistake i dont know :confused: This is the error message i get:

‘List’ does not contain a definition for ‘length’ and no accessible extension method ‘length’ accepting a first argument of type ‘List’ could be found (are you missing a using directive or an assembly reference?) Curve_Length

Here is the code:

        Brep geom = new Brep();
        double interval = 0.05;


        DA.GetData(0, ref geom);
        DA.GetData(1, ref interval);


        BoundingBox bb = geom.GetBoundingBox(true);
        double zmax = bb.GetCorners()[4].Z;


        Curve[] krive = Brep.CreateContourCurves(geom, new Point3d(0, 0, 0), new Point3d(0, 0, bb.GetCorners()[4].Z), interval);



        var podelat = 5;

        DA.GetData(2, ref podelat);


        //Point3d[] tacke = new Point3d[podelat];      

        //krive[0].DivideByCount(podelat, true, out tacke);


        List<Plane> ravni = new List<Plane>();
        String code = "";
        String niz = "";


        niz += "VAR robtarget targetlist{" + podelat.ToString() + "}:=[";

        for (int i = 0; i < krive.Length; i++)
        {

            Point3d[] tacke = new Point3d[podelat];
            krive[i].DivideByCount(podelat, true, out tacke);


            Vector3d vektorY = new Vector3d(0, 1, 0);

            Vector3d vektorZ = new Vector3d(0, 0, 1);

            Vector3d vektorX = new Vector3d(vektorZ);
            vektorX.Rotate(Math.PI / 2, vektorY);


            for (int j = 0; j < podelat; j++)
            {

                Plane ravan = new Plane(tacke[j], vektorX, vektorY);
                ravni.Add(ravan);

            }


            
            
         

            for (int k = 0; k < **ravni. length**; k++)
            {
                Plane p0 = new Plane(new Point3d(0, 0, 1), new Vector3d(1, 0, 0), new Vector3d(0, 1, 0));

                List<Plane> ravnica = new List<Plane>();

                Quaternion q = new Quaternion();
                q = Quaternion.Rotation(p0, ravni[k * podelat]);

                code += "CONST robtarget Target_" + k.ToString() + ":=[[" + ravni[k].OriginX.ToString() + ", " + ravni[k].OriginY.ToString() + ", " + ravni[k].OriginZ.ToString() + "], [" + q.A.ToString() + ", " + q.B.ToString() + ", " + q.C.ToString() + ", " + q.D.ToString() + "],[0,0,0,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];" + "\n";
                niz += "Target_" + k.ToString();
                if (k < podelat - 1)
                {
                    niz += ", ";
                }
            }

        }

        
        
        DA.SetDataList(0, krive);
        //DA.SetDataList(1,tacke);
        DA.SetDataList(1, ravni);
        DA.SetData(2, code);

Try change “ravni.Length” to “ravni.Count” instead.

// Rolf

1 Like

Thank you so much ! Worked like a charm !

.Length; is for arrays, .Count; is for lists.

1 Like