Search code examples
c#methodsargumentsrhino3d

What is expected as argument for this method?


I am trying to use the DivideByLength method below based on the RhinoCommon SDK but I cannot understand what the third argument is. I have tried to write the code below based on this method but I get the following error message: Error: 'Rhino.Geometry.Point3d' is a 'type' but is used like a 'variable'

I thought the third argument was to specify that I wanted points as output and not doubles. What am I doing wrong?

Method:

Public Function DivideByLength ( _
    segmentLength As Double, _
    includeStart As Boolean, _
    <OutAttribute> ByRef points As Point3d() _
) As Double()

Code:

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

for(int i = 0; i < crv.Count;i = i + 2)
{
  pts.Add(crv[i].DivideByLength(nb, true, out Point3d()));
}

Solution

  • I think this might be what you're after. Your out parameter is an array of Point3d objects and it looks like you want to get a list of all of the ones in all of the returned arrays. So you'd have your list, and need to AddRange the results.

    List<Point3d> pts = new List<Point3d>();
    
    for(int i = 0; i < crv.Count;i = i + 2)
    {
        Point3d[] arr;
        crv[i].DivideByLength(nb, true, out arr);
        pts.AddRange(arr);
    }