As the standard way of connecting vertices in a spline has always been a personal pet peeve of mine I've made this small macroscript and assigned it to a keyboard shortcut. Before using that I'd occasionally stumble upon a case where Create Line method would ask me if wanted to weld the vertices and whether I picked Yes or No the new line wouldn't be created. This as well as some snapping issues made me write the script. So much for the background, I hope it will be useful for someone else as well.
macroScript connectSplineVertscategory: "Advanced"buttonText: "Connect Verts"toolTip: "Connect Spline Vertices"-- author: Vojtech Cada-- email: vojta@krypton.cz(if selection.count == 1 AND isKindOf (local obj = selection[1]) Shape then(local splineCount = numSplines objlocal knotCount = 0local knotPositons = #()fn drawLine2Points spline point1 point2 =(local index = addNewSpline splineaddKnot spline index #corner #line point1addKnot spline index #corner #line point2updateShape spline)for spline = 1 to splineCountwhere (local selectedKnots = getKnotSelection obj spline) != #() do(join knotPositons (for knot in selectedKnots collect getKnotPoint obj spline knot)if (knotCount += selectedKnots.count) > 2 do exit)if knotCount != 2 thenmessageBox "Exactly 2 vertices have to be selected."else drawLine2Points obj knotPositons[1] knotPositons[2])else messageBox "No spline selected!")
USAGE: Run the script and find it in the Advanced category in the Customize UI dialog. assign a shortcut to it, put it to quadmenu or toolbar, do whatever you may want to with it. Select two spline vertices and fire it up.
UPDATE: a version supporting multiple vertices is now available at ScriptSpot as Connect Spline Vertices.
DISCLAIMER: All scripts and snippets are provided as is under Creative Commons Zero (public domain, no restrictions) license. The author and this blog cannot be held liable for any loss caused as a result of inaccuracy or error within these web pages. Use at your own risk.


This Post needs Your Comment!
Leave a Comment