Hi all! Hello C# World!
I am trying to do an Interpolate Curve, but I do not understand How to use this Class.
Thanks in advance for any explanation about it!
Best
Andrés Obregón
// This is what I wrote inside a C# component:
CreateInterpolatedCurve-Error.gh (5.6 KB)
private void RunScript(ref object A, ref object P)
{
List<Point3d> pts = new List<Point3d>();
for (double i = 0.0; i <= 20.0; i = i + 1)
{
Point3d tempPt = new Point3d(i, Math.Sin(i), 0);
pts.Add(tempPt);
}
A = pts;
Polyline pl = new Polyline (pts);
P = pl;
Curve.CreateInterpolatedCurve iC = new Curve.CreateInterpolatedCurve(pts,3);
C = iC;
}
Hi @andresobregonlopez,
Take another look at the documentation for the static CreateInterpolatedCurve
method here:
https://developer.rhino3d.com/api/RhinoCommon/html/M_Rhino_Geometry_Curve_CreateInterpolatedCurve.htm
It returns an instance of the curve class so you can assign it like so:
Curve myInterpolated = Curve.CreateInterpolatedCurve(pts, 3);
Thanks Lando Schumpic!
It is working now!
Best!
private void RunScript(ref object A, ref object P, ref object C)
{
List<Point3d> pts = new List<Point3d>();
for (double i = 0.0; i <= 20.0; i = i + 1)
{
Point3d tempPt = new Point3d(i, Math.Sin(i), 0);
pts.Add(tempPt);
}
A = pts;
Polyline pl = new Polyline (pts);
P = pl;
Curve myInterpolated = Curve.CreateInterpolatedCurve(pts, 3);
C = myInterpolated;
}