Hey everyone,
I’m trying to project a curve using Transform.ProjectAlong in C#, but the result doesn’t match the ProjectAlong component in Grasshopper.
Any idea why? How can I get the same result in C#? Could it be a data type issue?
Ok. This one took me a minute to figure out what was going on. The primary issue is that you’re duplicating an arc-like curve which is trying to maintain it’s rigid arc status when it performs the transformation. Instead of calling DuplicateCurve, really what you want to do is to convert the arc into a standard curve, which internally calls a MakeDeformable method. When you convert the arc to a curve and then run the transformation on it, it will work as expected.
In fact, this is exactly what’s happening with the Grasshopper component. If you hover over the G-input, you’ll notice the data type for the input is an “arc-like curve”. But, if you hover over the G-output, the result of the transformation is a “planar curve”. The component has performed a casting operation to convert this into a curve before making the transformation.
So, ideally, you’re code should look like this:
private void RunScript(Curve x, Plane y, Vector3d z, ref object a)
{
var aa = x.ToNurbsCurve();
aa.Transform(Transform.ProjectAlong(y, z));
a = aa;
}