Adverti horiz upsell

Straighten Components 1.0.2 for Maya (maya script)

The python script takes a selection of vertices and straightens them.

License
Button download
1,327 Downloads

Reviews

Rating: 5.0
(6)

Compatibility

  • 2016, 2015, 2014, 2013, 2012

Operating Systems

  • Linux
  • Mac
  • Windows

History

Created:02/23/2016
Last Modified:04/10/2016
File Size: 7.33 KB

Keywords

straighten, Align, maya

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.

straighten_components_compare


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.
straighten_components_initstraighten_components_maxDistance
straighten_components_firstTwostraighten_components_lastTwo


Usage

  1. Select at least three components (vertices, edges ... see supported types) you would like to straighten.
  2. Call the script. The mode can be one of the three mentioned ones.

    from straighten_components import *  
    straighten_components(mode=
    "maxDistance")
straighten_components_maxDistance_usage


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 Bug System to report any bugs.
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.

People who favorited this item:

  • KittyX3
    KittyX3
  • ecosky
    ecosky
  • lil0s
    lil0s
  • Santi Gutierrez
    Santi Gutierrez
  • mike vayser
    mike vayser
  • sethael
    sethael
  • Mason Doran
    Mason Doran
  • eben
    eben