3D Viewport dependent alignment. It’s important to understand that this works in 2D based on your viewport–this operator doesn’t know about your vertices in 3d world space, only in 2d screen space.
Orthographic vs Perspective works.
Cosine ‘omega’ can be tweaked.
Uses a ‘least squares’ best fit approach.
Simple to add your own ‘fitting’ functions if you know python and the relevant math.
Usage:
‘w’ key specials menu → Select function
Toolshelf ‘Vertex Alignment’ panel.
Toolshelf Operator Panel to tweak values.
It works as you would expect-- select the vertices you want to align, line up your 3D viewport and activate the operator. You can use it to clean up lines on a mesh-- pinpoint a flow line error and straighten it up with a parabolic fit, etc.
Note: If you are using viewport splitting, use the ‘w’ specials key (with your mouse in the desired viewport) to reliably activate the alignment for the viewport you want.
This operator is different from ‘relax’ tools from other addons, this one lines up based on your 3D viewport and ‘solves’, so repeated use will not further affect the alignment.
Download: Version 0.2 (13 December 2013)
Requests and bugs:
If there are enough requests (or if I need it later on), I can add some extra fitting functions, outlier filtering, ‘solution tweaking’ (ie, in the operator menu I can show the variable solutions and provide the ability to tweak them/reuse them).
If you find any bugs, let me know and I’ll try fix them.
Great script :). In my case I have a problem because I use a similar script created by Witold Jaworski: http://airplanes3d.net/scripts-254_e.xml
In his version “Align” option works a little differently than the “1D linear”, but your code contains other options like “Parabolic” which is great.
The problem is… after installing your script I can not use code from Witold.
What could be the reason?
Yeah it looks like we were both using the same internal name for our operators-- I have updated the main post with a new link that should fix the issue.
Hopefully you don’t have a problem updating from the old version, but just in case follow these steps:
Great now I can use both scripts thx
I also have suggestion - is it possible that during “Parabolic” command first and last vertex may stay in its places?
Great suggestion ! I’ve updated the addon to now include ‘Anchored Boundaries’. It’s definitely more practical with that.
I also made some other changes, so now it should be able to find the best fit, faster and more accurately. Sometimes it’ll still go off-the-wall, you’ll just have to change view slightly. It will also be possible to easily add n-degree polynomial fitting, but I’ll leave that for next time.
Thanks for checking it out ! I’ve changed the name and uploaded it to github. I’ll look into the third suggestion.
It would also be great to have an alignment in the XYZ axis, using the active vertex as center of that alignment.
I usually “flat” the vertexes scalling them to zero in the desired direction but implementing it in your addon has sense.
@hd_ I have also another suggestion. I would remove the button from Properties menu. As it’s more for statistic.
WKey menu and ToolBox is good enough i think.