Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
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: import curve_correction curve_correction.toggle() 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. D. Algorithm: 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.