Home Coding, Scripting, Shaders

(MEL) How to get selection center for scaling faces

polycounter lvl 16
Offline / Send Message
onionhead_o polycounter lvl 16
Im trying to write a piece of code that requires the selected faces to be scaled at their selection center. scale command requires a pivot XYZ, or else it will try to scale in the origin. I tried using xform -q -sp -ws, but that doesnt give me the pivot for select center. Well at least its not the one the scale cmd takes. From what i can tell maya uses cm default  for the pivots.

Replies

  • onionhead_o
    Offline / Send Message
    onionhead_o polycounter lvl 16
    after some thorough digging around the internet.  I found a way. Might be useful to some peeps
    setToolTo Move; float $pivot[] = `manipMoveContext -q -p Move`; //gives pivot position from selection
    xform -q -rp -ws; //gave object pivot only
  • onionhead_o
    Offline / Send Message
    onionhead_o polycounter lvl 16
    after some thorough digging around the internet.  I found a way. Might be useful to some peeps

    setToolTo Move;
    float $pivot[] = `manipMoveContext -q -p Move`;

  • breravin
    I'm always amazed when a question I need answered has only been answered just a week or two ago. Especially for a program like Maya which over 20 years old. 

    I'm not a scripter, I have a quick follow up question. So the script gives the pivot position, but then how would I use that position to scale something? Eg. scale 4 selected vertices to the center of their position (i.e. 0 0 0) 

    setToolTo Move;
    float $pivot[] = `manipMoveContext -q -p Move`;
    scale -? 0 0 0;  

    Setting something like this just scales the selected vertices way off in space:

    setToolTo Move;
    float $pivot[] = `manipMoveContext -q -p Move`;
    scale -r -p $pivot[0] $pivot[1] $pivot[2] 0 0 0;
  • breravin
    Ok, I found the issue. My scene is in meters and the script assumes centimeters. So it was working - it was just moving the  vertices 100 times too far. Now I just need to track down how to make the script run Working Unit agnostic. 
Sign In or Register to comment.