Home Technical Talk

center to world in maya

polycounter lvl 11
Offline / Send Message
Yozora polycounter lvl 11
Freezing transformations only work locally and I'm really surprised I can't find anything to center an object to the world.

Heres what I do to center objects;

1) Click on object
2) If the pivot point is not at the center of the object then I use "center pivot to object" or move the pivot to wherever I want the center to be.
3) "W" (move)
4) Click one of the arrows but don't actually move the object anywhere, the world coordinates appear at the bottom status bar thingy.
5) Note down all 3 XYZ coordinates and then reverse them (add negative if its a positive and vice versa)
6) Type them one at a time into the XYZ input boxes on the top tool bar and then hit enter


So is there a easier way to center something to the world like clicking on a "center to world" button? :/

Replies

  • MoP
    Offline / Send Message
    MoP polycounter lvl 18
    You can set the position of an object absolutely using the input boxes at the top of the toolbar, just click the drop-down to the left of them and choose "absolute XYZ" instead of "relative XYZ" (I think that's what they're named anyway, might be world / local).
    Then you can just type 0 0 0 in the boxes and hit Enter.

    If you find yourself doing this a lot, it'd be very easy to open the MEL listener after doing those commands, and paste them into a Shelf button (would basically do Center Pivot to Object, then do Absolute Move to 0 0 0).
  • ivars
    Offline / Send Message
    ivars polycounter lvl 17
    Yozora wrote: »
    4) Click one of the arrows but don't actually move the object anywhere, the world coordinates appear at the bottom status bar thingy.
    5) Note down all 3 XYZ coordinates and then reverse them (add negative if its a positive and vice versa)
    6) Type them one at a time into the XYZ input boxes on the top tool bar and then hit enter

    Or just snap it to the grid (x) If your object is far away from the center of the grid, just zoom in on origo, and use MMB to snap it there.

    Or what MoP said :)
  • Yozora
    Offline / Send Message
    Yozora polycounter lvl 11
    MoP wrote: »
    You can set the position of an object absolutely using the input boxes at the top of the toolbar, just click the drop-down to the left of them and choose "absolute XYZ" instead of "relative XYZ" (I think that's what they're named anyway, might be world / local).
    Then you can just type 0 0 0 in the boxes and hit Enter.

    If you find yourself doing this a lot, it'd be very easy to open the MEL listener after doing those commands, and paste them into a Shelf button (would basically do Center Pivot to Object, then do Absolute Move to 0 0 0).


    The drop down only lets you do "absolute" and "relative", neither of which do what I want it to do (I just tried it, can someone else try it to confirm as well? Make sure when you do try it, that the object is not already at 0 0 0... so move it somewhere, and then freeze transformations and then try to center it to the world)
    The "absolute" just treats the object locally and the relative seems to do nothing at all?

    But thanks ivars, your snap to grid solution works fine, and is quicker than typing in 0 0 0 into 3 boxes even if it did work so yea, thanks again :p
  • sama.van
    Offline / Send Message
    sama.van polycounter lvl 17
    終わった!!

    Tell me if the tools is what you need :)

    (if someone can give to me a right name for this script... it'll welcome.... XD)

    >>> SAMA_Yozora_Tools_A Script <<<

    SAMA_Yozora_Tools_A.jpg
  • Yozora
    Offline / Send Message
    Yozora polycounter lvl 11
    Yea this script works fine Sama van, but it would be even better if it automatically inputs 0,0,0 so you dont have to type it in yourself :)

    And I think a good name would be "center_to_world"

    Thanks for that!
  • Toast
    Offline / Send Message
    Toast polycounter lvl 11
    Late reply, but this will transform an object to centre of the world even it has frozen transforms.
    xform -ws -t 0 0 0;
  • Yozora
    Offline / Send Message
    Yozora polycounter lvl 11
    Toast wrote: »
    Late reply, but this will transform an object to centre of the world even it has frozen transforms.


    Just tried it, doesnt work... It just moves it back to the local 0,0,0
  • Toast
    Offline / Send Message
    Toast polycounter lvl 11
    Sorry, I meant to say it will transform to world centre if transforms aren't frozen.

    That way you could mod sama.van's code and add in the xform line so it automatically goes back to world center. I should have checked what I typed first.
  • neosca
    Offline / Send Message
    neosca polycounter lvl 3
    since the above link for the center to world script was broken, I am pasting the mel script below. 
    Steps:
    1. Select your mesh,
    2. Center pivot by clicking on Modify>Center Pivot.
    3. Open script editor and in mel tab, paste the following: move -rpr 0 0 0 ;
    4. Run the script.
  • TTools
    Offline / Send Message
    TTools polycounter lvl 4
    These might do what you are looking for.  The first link will move all selected objects back to the origin regardless of whether the transforms are frozen or not.
    https://www.youtube.com/watch?v=tfmX8nW8pKA&feature=youtu.be

    The second link will restore world translation data back to objects that have been frozen.
    https://www.youtube.com/watch?v=f_NOH0RCw2g&feature=youtu.be
  • laomusicArts
    Offline / Send Message
    laomusicArts polycounter lvl 4
    Hi! Here it is my solution to move ANY selected object back to the center of the world: - create a MEL tab and copy/paste this snippet: // Get the selected object(s) string $selectedObjects[] = `ls -sl`; // Check if any objects are selected if (size($selectedObjects) > 0) { // Loop through each selected object and move it to the origin for ($obj in $selectedObjects) { // Move the object to the origin using -rpr to preserve the parent transformation move -rpr 0 0 0 $obj; } print("Selected object(s) have been moved to the center of the world.\n"); } else { print("No object selected. Please select an object to center.\n"); } This script does the following: 1. `ls -sl` lists the currently selected objects and stores them in the `$selectedObjects` array. 2. It checks if any objects are selected using the `size($selectedObjects)` function. 3. If objects are selected, it iterates through each object in the array. 4. The `move -rpr 0 0 0 $obj;` command moves each object to the origin, preserving the parent transformation. 5. If no objects are selected, it prints a message prompting the user to select an object. Hope this helps others too! LAO
Sign In or Register to comment.