Grasshopper

algorithmic modeling for Rhino

C#: Can't convert 'Rhino.Geometry.Curve[]' to 'Rhino.Geometry.Curve'

Hello,

I am trying to join curves in the C# component in Grasshopper and am getting this message:

Error (CS0029): Eine implizite Konvertierung vom Typ 'Rhino.Geometry.Curve[]' in 'Rhino.Geometry.Curve' ist nicht möglich. (line 85)

Unfortunately I don't know how to have it displayed in English but it is saying that it can't convert 'Rhino.Geometry.Curve[]' to 'Rhino.Geometry.Curve'. This is my code:

    Point3d pt1 = new Point3d(0, 0, 0);
    Point3d pt2 = new Point3d(1, 0, 0);
    Point3d pt3 = new Point3d(1, 1, 0);
   
    Line line1 = new Line(pt1, pt2);
    Line line2 = new Line(pt2, pt3);
   
    Curve crv1 = line1.ToNurbsCurve();
    Curve crv2 = line2.ToNurbsCurve();
   
    List <Curve> crvlist = new List<Curve>();
    crvlist.Add(crv1);
    crvlist.Add(crv2);
   
    Curve joined = Curve.JoinCurves(crvlist);
   
    A = joined;

What needs to change? Also, do I really need to convert things like lines etc. to NurbsCurves each time I do this, or is there a more direct way? I am quite new to C# and would be thankful for any tips on how to make the above code shorter and more efficient.

Cheers,

Max

Views: 2020

Replies to This Discussion

Aaaaaahhhhhh...

The JoinCurves method Returns an Array of curves (right?), therefore it must be

    Curve[] joined = Curve.JoinCurves(crvlist);
   
    A = joined;

Yup, because there is no guarantee that all the curves you provide can be joined into a single result.

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service