Grasshopper

algorithmic modeling for Rhino

C# Converter -> points.ConvertAll(new Converter<Point3f, Point3d>( ? ) );

Hi,

How can I convert List of point3f points to point3d.

I want to use ConvertAll function, but I do not know how to finish it:

List<Point3d> pts = points.ConvertAll(new Converter<Point3f, Point3d>(Point3d(Point3f)target);

What has to be typed instead of bold text ?

Thanks,

Tomas

Views: 1147

Replies to This Discussion

I think you have to write a method that you pass in as a delegate. You probably can't use anonymous methods in the C# editor.

List<Point3d> pts = points.ConvertAll(Convert3fTo3d);

...

/// additional code

private Point3d Convert3fTo3d(Point3f point)

{

  return new Point3d(point.X, point.Y, point.Z);

}

Nice thanks:)

Now a days it is probably preferred to use the select LINQ extension method:

var doublePrecisionPoints = singlePrecisionPoints.Select(p => new Point3d(p.X, p.Y, p.Z));

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service