Adverti horiz upsell

AutoAlignComponentsToPlaneTool 1.0.0 for Maya (maya script)

This python script allows you to align a set of vertices/edges/faces on to a single plane in Maya.

License
Button download
1,037 Downloads

Compatibility

  • 2016, 2015, 2014

Operating Systems

  • Mac
  • Windows

History

Created:11/02/2015
Last Modified:11/02/2015
File Size: 7.88 KB

Keywords

Align, face, maya

Q/A

ERROR

Date:02/01/2016
Submitted by: Lukas Müller Lukas Müller
Hi
I've successfully installed numpy in maya 2016 (for mac).

When clicking "set" in your script, the following error pops up in the script editor:
"# Error: NameError: file <maya console> line 1: name 'alignVtxToPlane' is not defined #"

what did i do wrong? 

thanks in advance 

Replies to this question:

  • Replyindent
    Ken Jiang

    Ken Jiang said almost 9 years ago:

    Hi Lukas Thanks for trying out my script. Looking at your error, it seems that function 'alignVtxToPlane' in the script was not defined correctly. Could you elaborate on how you loaded the script so I can recreate the problem on my mac?
  • Lukas Müller

    Lukas Müller said almost 9 years ago:

    i followed this tut to run the script in maya (or add it to the shelf): https://www.samwirch.com/blog/importing-and-running-external-python-scripts-maya-2011 so it looks like this: import sys import os def psource(module): file = os.path.basename( module ) dir = os.path.dirname( module ) toks = file.split( '.' ) modname = toks[0] # Check if dirrectory is really a directory if( os.path.exists( dir ) ): # Check if the file directory already exists in the sys.path array paths = sys.path pathfound = 0 for path in paths: if(dir == path): pathfound = 1 # If the dirrectory is not part of sys.path add it if not pathfound: sys.path.append( dir ) # exec works like MEL's eval but you need to add in globals() # at the end to make sure the file is imported into the global # namespace else it will only be in the scope of this function exec ('import ' + modname) in globals() # reload the file to make sure its up to date exec( 'reload( ' + modname + ' )' ) in globals() # This returns the namespace of the file imported return modname # When you import a file you must give it the full path psource( '/Users/Lukas/Library/Preferences/Autodesk/maya/2016/scripts/AutoAlignComponentsToPlaneTool_v_1_0.py' )
  • Replyindent
    Ken Jiang

    Ken Jiang said almost 9 years ago:

    Oops, my mistake. The script you posted is correct. Okay, I figured out the problem. The web tutorial you followed only calls the main functions (In this case, the UI part of the code) which means that the GUI is displayed but the other functions like 'alignVtxToPlane' (The part where the script tells what to do when the 'set' button is pressed) is left out. All you have to do to resolve this issue is to open the script normally, which is explained at the earlier answer I posted. Hope this helps.
  • Replyindent
    Ken Jiang

    Ken Jiang said almost 9 years ago:

    I looked through the script you posted. I think you left out a line at the bottom?
  • Lukas Müller

    Lukas Müller said almost 9 years ago:

    oh and it's the first time i'm trying to run an external py script in maya... so this instructions are the first google found... in your manual you just write "load the python script in maya". i've no clue how to achieve this. Thanks for your help!
  • Replyindent
    Ken Jiang

    Ken Jiang said almost 9 years ago:

    The web tutorial you followed earlier is one way to load an external python script, but it is primarily intended for developers who wants to edit scripts on an external code editing program like emacs or IDLE. For someone who only wants to use the script in Maya's script editor, you simply go to File -> Load Script and select the python file you want to use. It will load the script on the python tab and you simply push the execute button.
  • Lukas Müller

    Lukas Müller said almost 9 years ago:

    great, it worked like a charm! loaded the script as you told me and added it to the shelf! thx for your time!

Post a reply: