I am working on a GhPython script and am running into an error with curve flipping. I want the direction of the curve to change- the start and end should swap places. The .Reverse() method seems to be flipping the tangent vector, but not the actual point on curve.

Both output a and b are in the same location rather than on opposite sides of the curve. I tried to use the flip component and am getting the same results. I’ve isolated the problem in the attached script.

@MarcusStrube, your example is pretty good. But why are you normalizing the domain? The domain in this case should be correct.

Its not often that you need to reparameterize a curve or surface. Keep in mind that poorly parameterized objects may not intersect and trim properly when combined with other objects. “Poorly parameterized” means the curve’s domain or the surface’s u or v spaces are tiny or huge compared to the size of the object…

I’m in a situation where I do not want to have to redraw the curve. What is the best way to get temp2 to appear as if it was drawn as line from y to x (instead of x to y)? I don’t want to deal with negative domains.

So reparameterizing is something I’ve been curious about. In my example I only tried to get the start point on the curve, but that is not always the case. I almost always reparameterize my curves and surfaces so that I can work between 0:1. If I don’t reparameterize, how do I get a point at the middle or quarter from the start or quarter from the end? Would I have to get the domain, multiply by the fraction (.5, .25, .75) and then do .PointAt(t)?

# Returns a point on a curve at a normalized parameter
def GetCurvePointAtNormalizedParameter(curve, norm_t):
if not curve:
raise Exception("Curve is null")
if norm_t < 0.0 or norm_t > 1.0:
raise Exception("Parameter not normalized")
rc, curve_t = curve.NormalizedLengthParameter(norm_t)
return curve.PointAt(curve_t)

I think in GH the situation is a bit different, because when you divide a lot of curves to draw even more curves, Curve.PointAtNormalizedLength can be your bottleneck as it keeps doing the same calculation over and over again.