Problems changing the seam of a closed curve in Grasshopper C# Script

I am developing a group of scripts in c# to design, move and stabilize meshes of Reciprocal Transformable Frame structures, which basically are group of beams that are mutually tangent and form a serie of closed structural circuits. The main issue is that they are transformable structures, able to move when the user modify parameters, but always maintaining the tangency between bars.

Each of the bars is built from a given one by three parameters:

  • the normalized distance on the axis of the reference beam. This sets point P1
  • the normalized length on the circle orthogonal to the given axis with radius the desired eccentricity between beams. This parameter sets point P2.
  • the normalized length on the circle orthogonal to vector P2P1 and radius the desired length of the beam. This sets point P3 on this circle so the new beam’s axis is vector P3P2.

//Function to get the axis of a cylinder tangent to another one
public Line getNextAxis(Line A1, double R, double L, double param1, double param2, double param3, List Tpartial)
Line result;

LineCurve a1 = new LineCurve(A1);
Vector3d e1 = A1.Direction;
Vector3d e2 = new Vector3d();
Vector3d V = new Vector3d();
Point3d P1 = new Point3d();
Point3d P2 = new Point3d();
Point3d P3 = new Point3d();
Point3d T = new Point3d();
Plane pl1;
Plane pl2;
Circle C1;
Circle C2;
Curve c1;
Curve c2;

P1 = a1.PointAtNormalizedLength(param1);

pl1 = new Plane(P1, e1);
C1 = new Circle(pl1, 2 * R);
c1 = C1.ToNurbsCurve();
P2 = c1.PointAtNormalizedLength(param2);

//Param 3
V = P2 - P1;

pl2 = new Plane(P2, V);
C2 = new Circle(pl2, L);
c2 = C2.ToNurbsCurve();
P3 = c2.PointAtNormalizedLength(param3);

//Add Tangent point to a reference external list
T = P1 + R * V;

//new axis
e2 = P3 - P2;
result = new Line(P2, P3);

return result;


In order to control the final geometry of the whole reciprocal mesh, I have to numerically control the values of the parameters, but they depend on the start point that grasshopper is considering on the circles I generate. The problem is that, if I change the second parameter (length on the first circle) sometimes it change the position of the start point of the second circle

I have tried to set a new seam on circle two (the one or radius Length) by:

//Function to change the Start Point of the circle used to get the third point of the three-param beam.
//C is the circle as LineCurve, O1 is the origin of the circle, ei is the direction that I want the start point to be and R is the radius of the given curve C
public void changeSeamParam3(Curve C, Point3d O1, Vector3d ei, double R)
//Point where the circle is starting
Point3d S = C.PointAtNormalizedLength(0.0);

//Point where I want the circle to start 
Point3d Sn = O1 - R * ei;

Vector3d O1S = S - O1;
Vector3d O1Sn = Sn - O1;

//dot product of vectors O1S and O1Sn, so I get the cosine of the angle formed by them (it is a previously defined function)
double dotp = dot(O1S, O1Sn);

//Get the angle so I can get the Arc between them (param t) multiplying by the Radius
double alpha = Math.Acos(dotp);
double t = alpha * R;

//Change the start point by the parameter t


But the problem persists. I don’t know how to fix it and I am really quite desperate now
I would appreciate any suggestion you could give.

Thank you very much for your time,

I would strongly suggest to post the actual C# (+ any test data required).

Thank you very much,

but I’ve finally realized where the problem was: I was considering the parameter t of the new start point on the circle as the length between it and the original start point, which I wrongly believed was length 0. I found the parameter t with the ClosestPoint Method and then ChangeClosedCurveSeam to that parameter. Now works fine.

But thanks anyway

In general ALWAYS post an explicit AND stand-alone portion of the issue (in this case the actual C# - unless is classified [if so isolate the issue]).

Other than that I can hardly see the reason for treating tubes (or some other type like IPE, HEB, HEA or some hybrid combo like a tensegrity truss module etc etc) as meshes: If your structure(s) have a big N of items (real-life) and/or are some way “detailed” you should treat them as Instance Definitions (most probably nested) of Breps .