Description
The python script takes a selection of vertices and straightens them. This is done by moving those vertices perpendiculary to a defined main vector.
Features
The script supports the following component types (multi selection):
-
Polygon Edge (
MeshEdge
) -
Polygon Vertex(
MeshVertex
) -
Curve Vertex (
NurbsCurve
) -
Curve (
NurbsCurveCV
)
Currently there a three modes of defining the main vector:
-
maxDistance
(default): Take the vetices with the longest distance to each other and align the rest to that vector. -
firstTwo
: Take the first two selected vertices and align the rest to that vector. Important: See hint selection order at installation description. -
lastTwo
: Take the last two selected vertices and align the rest to that vector. Important: See hint selection order at installation description.
Usage
- Select at least three components (vertices, edges ... see supported types) you would like to straighten.
-
Call the script. The mode can be one of the three mentioned ones.
from straighten_components import *
straighten_components(mode="maxDistance")
Installation
Supported Platforms
The script was tested on Windows 7 64bit with Maya 2012 to 2016. As it does not use any platform dependent code, it should work for Linux and Mac OS X as well.
Where to put the file straighten_components.py?
1) You basically have to put the script in the scripts folder either in a self defined path (MAYA_SCRIPT_PATH
) or just into Maya's default project:
- Linux: $HOME/maya
- Mac OS X: $HOME/Library/Preferences/Autodesk/maya
- Windows: \Users\\Documents\maya
Another solution would be to source the script manually via the folowing python code:
import sys
sys.path.append('MY_PATH')
from straighten_components import *
For further information. There is a detailed description how to Installing a Maya plug-in in the Autodesk Knowledge Base.
2) Inside Maya, open up the script editor. Then copy the following lines into a python tab (not MEL!):
from straighten_components import *
straighten_components(mode="maxDistance")
Hit Ctrl+Enter
3) If you want a shelf button, just select those two lines above and drag the selection up to the shelf using your Middle Mouse Button.
Selection Order
Furthermore, in order to use the modes firstTwo
and lastTwo
you need to make sure that you have activated the tracking of the selection order. To do this you have those options:
- Turn the option on in Maya preferences:
Preferences > Selection > Track selection order - Python call:
import maya.cmds as cmds cmds.selectPref(trackSelectionOrder=True)
- Mel call:
selectPref -trackSelectionOrder true ;
Please use the Feature Requests to give me ideas.
Please use the Support Forum if you have any questions or problems.
Please rate and review in the Review section.