Convert closed curve to straight line

Is there a way to convert a closed or non planar curve to a straight line? At the moment I am using _length and then creating a straight line to that spec but sure there must be a better way.

I use the straight line as my base curve to work on the flat and then _flow back to the original closed or non planar curve.

I don’t know either. As you probably know with surfaces, they can be unrolled and need to be for many operations such as applying textures from pictures to a cylinder. But they arent’l limited to cylinders.

In the meantime, heres a quickie macro.
! _length
_noecho
_line 0 pause pause enter
_sellast
_move

The no echo keeps the beginning of the line command short and able to see the result from length.

  1. select your curve before you click your button, or run the macro
  2. The length will be in the command history, simply enter the length in command line, hit enter.
  3. Pick where you want the end of the line from 0, click in whatever viewport, use constraints, etc.
  4. pick where to move your line from and to

pretty quick, but copying the #result of the command length (a variable) to a line command seems like a pretty easy script to make! a 5 minute macro button might do though if this is a regular thing you do.

the basic python script would be:

import rhinoscriptsyntax as rs
crv= rs.GetCurveObject ('Select a curve to straighten')
length = rs.CurveLength(crv[0])
rs.AddLine((0,0,0),(length,0,0))

Thanks both for your answers, thought that there must be some Rhino command for this that I was missing.

I use a lot of macros via alias` but I think it is time to get stuck into some scripting. Found the python editor and the library.

Thanks again.

@jeff_hammond Excellent ! You beat me to it…

–Mitch

1 Like

haha
i wonder where i learned how to do that.

@Helvetosaur last piece of the puzzle was to figure out how to handle the scripts. Found the answers for that in this post of yours. Thanks.

Still working on it but this is pretty much doing what I want now. Thanks again.

    import rhinoscriptsyntax as rs
    
    object = rs.GetObject("Select a curve")
    if rs.IsCurve(object):
     length = rs.CurveLength(object)
    
     # create variable to orient the crv from the middle
     middle = length/2
    
     # prompt for distance above or below original curve
     gap = rs.GetInteger("distance above/below", 0)
    
     # orient curve for different views
     viewName = rs.CurrentView( return_name=True )
     if viewName in ("Left","Right"):
      rs.AddLine((0,-middle,gap),(0,middle,gap))
     elif viewName in ("Top","Bottom"):
      rs.AddLine((-middle,gap,0),(middle,gap,0))
     else:
      rs.AddLine((-middle,0,gap),(middle,0,gap))
1 Like

You da man Jeff, better luck next time Mitch! Just kidding, thank you both for the wonderful curve tools. Mitch’s measuring, and Jeff’s straighten.

wow, can’t believe the python script is shorter than the crappy macro darn near, but did figure it was quite easy. But it is a new curve though, not actually modifying the actual input. Much quicker and cleaner than actually straightening it would ever be.