Use toggle() to toggle between on/off states, assigning/killing script jobs, who monitor curves selection and creation, and apply correction automatically.
Use soft select falloff radius to set the threshold for the test if the curve edges of the correcting curve are close enough to the first curve in order to apply the correction.
1. Put the script in PYTHONPATH (e.g. C:/Documents and Settings/<user>/My Documents/maya/scripts).
2. Make a shelf button from the following code or simply run it:
3. Draw one curve or select one curve.
4. Draw another curve close to it. Closeness is determined relatively to the falloff radius of the soft select tool (Hold b and LMB while moving the mouse horizontally).
5. Features and notes:
A. It attaches lines automatically.
B. It closes the first curve automatically if both ends of one curve are close to both ends of the other curve.
C. The orientation of the second curve matters - it matters from where you start drawing.
1. It locates on cur1 the closest point to each one of the two ends of cur2.
2. It detaches curve1 in these two points, splitting it to 3 curves: dc0, dc1, dc2.
3. dc1 is deleted.
4. cur2 is attached to dc0 and dc2.