Straighten a path

Moho allows users to write new tools and plugins. Discuss scripting ideas and problems here.

Moderators: Fahim, Distinct Sun, Víctor Paredes, erey, Belgarath, slowtiger

Post Reply
Posts: 2195
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

Straighten a path

Post by hayasidist » Thu Oct 24, 2019 12:42 pm

This tool makes the selected paths(s) straight and preserves the segment lengths between points. (works only on "open" - i.e. not closed / fillable curves)

It's a menu tool at present -- I'd suggest <your custom folder> scripts / menu / draw as the destination folder

select one point on a curve as the anchor point, and the other points will move away from that point in a nice straight line along either the x or y direction according to the aspect ratio of the starting curve ... h.lua/file

three example use cases:
- you've drawn a line that's nearly straight and you want it dead straight. Use the tool on frame 0.
- you've drawn a coil of rope and you want it to be pulled out straight. select an end point and use the tool on (e.g.) frame 75
- you've got a curly line (e.g. a hair curl) and you want it to bounce. use the tool on (e.g.) frame 50. find a point (e.g. frame 7) that has just the right amount of displacement and add a keyframe for all the points. delete the frame 50 key; move the frame 7 key to where the timing of the bounce is right for you (e.g. frame 20); copy the frame 0 key to about twice that (e.g. frame 39) and make it cyclic back to frame 1.

you can, of course, put the vector layer in a bone group for added dynamics.

a known "feature" is using this with a curve created using freehand where the way the Bezier handles are set up can lead to kinks in the resulting line. I decided that it was better to leave the kinks in -- some materials when you pull them never actually come out straight -- but/and these are easily managed if need be by manually keying curvatures to straight over the last few frames of the straightening.

will not work with anything before AS11.

comments / bug reports / feature requests all welcome.
User avatar
Posts: 2491
Joined: Mon Aug 09, 2004 6:06 am
Location: Australia

Re: Straighten a path

Post by DK » Fri Oct 25, 2019 11:03 am


Love this script! Here's a simple worm done using the script :)

Thanks hayasidist!

Post Reply