[addon][mesh] 3D Viewport Vertex Alignment

Vertex Align Operator

This operator aligns selected vertices in the 3D viewport to a selected fitting function.


Features:

  • 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.

Thanks

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?

Thanks for checking it out :slight_smile:

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:

  1. Deactivate and remove old script
  2. Install new script
  3. Save preferences
  4. Restart blender

Great now I can use both scripts thx :slight_smile:
I also have suggestion - is it possible that during “Parabolic” command first and last vertex may stay in its places?

Great addon! That’s what i need!
Thanks a lot!!!

Suggestion:

  • rename addon to mesh_vertex_alignment_operator.py or mesh_vertex_alignment.py to get the same convention of other official scripts.
  • create your repository like on www.github.com to have source always available with recent commits.
  • ask the script for review to put it into the official blender release. http://developer.blender.org/ (see “Submit Addon”)

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.

Hey! give us the new link to the addon repo, please. :slight_smile:

Also can you create a wiki page? It will be useful too.
I huess you need to make it here (need to register and login to edit wiki pages) http://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts/Mesh

Also will you be committing to github always? Just to get latest sources of your script.

The link is in the main post, but here it is again:

I’ll be committing to github with any stable changes I make.

I’ll see what I can do about the wiki.

Thanks !

Thank you very much for this update. Your script should be in the official version of blender.

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. :slight_smile:

Screen:

I get this error:


hi, I’ve very quickly fixed this script. let me know if it works ok.
https://github.com/meta-androcto/blenderpython/blob/master/scripts/addons_extern/mesh_viewport_vertex_alignment.py