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,320 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

Q/A

Help Installing Plugins For A Noob

Date:03/17/2016
Submitted by: Derpnet Derpnet
 Hello there. I am very new to dealing with Maya and its esoteric way of doing things, especially when it comes to installing scripts and plugins. Given my verible lack of understanding this is how I tried to do it.

I created and dropped a Maya.env file in C:\Users\Username\Documents\maya\2016

 This is what it looks like inside:

MAYA_PLUG_IN_PATH - C:\Users\Username\Documents\maya\2016\plug-ins

MAYA_SCRIPT_PATH - C:\Users\Username\Documents\maya\2016\scripts

XBMLANGPATH - C:\Users\Username\Documents\maya\2016\icons

 When I start Maya 2016 SP5 I open the plugin manager and there is a new group showing the straighten_components.py script. I try to check it but instead I get the following error:

// Warning: line 1: No initializePlugin() or initializePlugin2() function
 //
# Error: pymel : Failed to get controlCommand list from straighten_components #
# Error: pymel : Failed to get modelEditorCommand list from straighten_components #
# Error: pymel : Failed to get command list from straighten_components #
# Error: pymel : Failed to get constraintCommand list from straighten_components #
# Error: pymel.core : Failed to get depend nodes list from straighten_components #
// Error: line 1:  (straighten_components) //

 I have no formal programming knowledge (and all attempts were horrific failures) so I do have even the most remote idea as to what is going on.

 Thankyou for the help.

Replies to this question:

  • sebas-td

    sebas-td said over 8 years ago:

    Hi Derpnet, actually you are almost there. What you tried, is loading the python script as a plugin. That's the reason why you are getting those error messages. You don't need the Plug-In Manager for a script. I am not even sure, why the script showed up in the Plug-in Manager. It shouldn't. Did you eventually copy the straighten_components.py file into the plug-ins directory? Anyway. If you copy the straighten_components.py file into your "C:\Users\Username\Documents\maya\2016\scripts". You are ready to go. 1) Select the points or edges you want to straighten 2) Open the Script Editor (Windwos>General>Script Editor) and go into the python tab. The only thing you have to do is to copy these lines into that python tab: from straighten_components import * straighten_components("maxDistance") 3) Select the lines in the python tab 4) Hit Ctrl+Enter That's it. Tip: In order to avoid using the script editor in the future. Just select the two mentioned lines in the script editor and middle-Mouse-Drag those into your shelf (e.g. Custom). From there you have the script always ready to run. If you still have issues running the script. Let me know. Cheers Sebastian
  • Replyindent
    sebas-td

    sebas-td said over 8 years ago:

    Hi Derpnet, # Your Question It is actually already in the code. Instead of calling straighten_components("maxDistance") you can call straighten_components("firstTwo") and it will take the first two selected vertices as the main axis to which every other vertex will be moved. Note, that this is only working if you activated the "selection order tracking" (see description) # Your problem That's strange. What kind of component did you select? Poly Vertices or Curve Vertices or even edges? Can you provide me a small test file (*.ma or *.mb).
  • Replyindent
    Derpnet

    Derpnet said over 8 years ago:

    I SAY WHAT! WHAT! It worked! There is one small problem and one small question. The problem is that when I try to undo the operation all of the verts snap to the center of the world, completely zeroed out and no amount of undos fix it. My small question is when reading about the variety of ways you can use the script I got the impression that by changing a portion of the code you could change how the script overall functions. Say change straighten_components("maxDistance") to straighten_components("firstTwo")? Will this have the expected effect or is the feature already in the script. I am going to bed now so I will not have time to muck around P.S. Yup, I put the script in the plugins folder. That is why derp is in my username. Thanks again!
  • Derpnet

    Derpnet said over 8 years ago:

    Can you P.M. me your email so that I can send a copy of the scene I was working on? I deleted all but one model in it as the script borked any model I used it on. It works fine in a brand new scene but not the one I was working on. P.S. It actually snaps all verts to the center of the pivot when I undo and it does not matter if I had used it on verts or edges.
  • Replyindent
    Derpnet

    Derpnet said over 8 years ago:

    Sorry if this get posted multiple times, the website just kept refreshing everytime I clicked reply. Anyhoo... PROBLEM FIXED!!! I work in meters as I am work on some very large machines and it is easier to think of decimal divisions of tens instead of hundreds (and sometimes thousands) of smaller units.
  • Replyindent
    sebas-td

    sebas-td said over 8 years ago:

    Hi Derpnet, I just had a look into your file and tracked it down. Your file uses "Meter" as units. As soon as you switch to centimeter it is working fine. But this is definitely a bug and you should not be forced working in centimeters. # FYI Start I tried different things. Apparently there is a bug in the underlying scripting environment called pymel. I tried similar stuff with the other available environments MEL and Python. It is not happening there. # FYI End I made some code changes (pymel>python) and uploaded a new version of the script (1.0.1). It is working now. Please let me know if you still run into issues. Cheers Sebastian
  • Replyindent
    sebas-td

    sebas-td said over 8 years ago:

    Hi, I tried to send you a p.m. but always received an error message. Just write me at this email: sebas-td@outlook.com Cheers, Sebastian

Post a reply: