添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

I create a List< Line> alpha and a List<List< Line>> beta.
Add to alpha a bunch of lines.
beta.AddRange(alpha);

Error:

  • Error (CS1502): The best overloaded method match for ‘System.Collections.Generic.List<System.Collections.Generic.List<Rhino.Geometry.Line>>.AddRange(System.Collections.Generic.IEnumerable<System.Collections.Generic.List<Rhino.Geometry.Line>>)’ has some invalid arguments
  • Error (CS1503): Argument 1: cannot convert from ‘System.Collections.Generic.List<Rhino.Geometry.Line>’ to ‘System.Collections.Generic.IEnumerable<System.Collections.Generic.List<Rhino.Geometry.Line>>’
  • What’s the problem? How is one of the category System.Collections.Generic.IEnumerable & the other System.Collections.Generic.List?

    Thank you.

    Line is a protected constructor and should be replaced by a List containing curves and then add them as NurbsCurve.

    something like this:

    Curve crv = new Line(pt0,pt1).ToNurbsCurve();
    beta.Add(crv);
    

    for your example, List<Line> should be replaced by List<Curve> and the Lines added as NurbsCurve.

    benedict:

    Line is a protected constructor and should be replaced by a List containing curves and then add them as NurbsCurve.

    No - do not convert lines to NURBS curve.

    Do this instead:

    var line = new Line(pt0, p1);
    var line_curve = new LineCurve(line);
    beta.Add(line_curve);
    

    – Dale

    Oh, sorry I mislead then.
    Must have missed out that one…
    LineCurve? is that one new or did I miss it since ever?

    Ben back in NooB modus :slight_smile: