Another easy question...

43 views
Skip to first unread message

Aren Voorhees

unread,
Mar 3, 2014, 11:39:54 AM3/3/14
to python_in...@googlegroups.com
Hi there,

I am looking for a way to move an object to a specific location in world space.  I tried this with xform() and move(), but so far I can only figure out how to move objects a certain number of units from where it currently is.  Instead, I want to move the object TO a specific place, regardless of where it is currently.  

For example, say I have an object somewhere in the world with it's transformations frozen and I want to to move it to, say exactly [10,0,0].  If anyone could give me a nudge in the right direction, I'd really appreciate it!  

Thanks,
Aren

Eduardo Grana

unread,
Mar 3, 2014, 12:18:14 PM3/3/14
to python_in...@googlegroups.com
Hello Aren,

Maybe you want to try using the flags -a for aboslute and -ws for worldspace in your move command,
for example:

import maya.cmds as mc
sphere = 'pSphere1'
mc.move(0,10,0, sphere, a=1, ws=1)
# this should move your sphere to 0,10,0 in worldspace

Cheers!
Eduardo


--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/0018130d-44ac-417b-bba8-92444fe0fbc4%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
Eduardo Graña
www.eduardograna.com.ar

Marcus Ottosson

unread,
Mar 3, 2014, 1:02:58 PM3/3/14
to python_in...@googlegroups.com
Take care when freezing transformations, the translate values you had in the channel box are moved to the pivots of your object, making it seem as though its off the center of the world.

To be really sure where you're moving your objects to and from using worldspace values, make sure you clear out these attributes:

- pCube1.rotatePivot
- pCube1.scalePivot



For more options, visit https://groups.google.com/groups/opt_out.



--
Marcus Ottosson
konstr...@gmail.com

Aren Voorhees

unread,
Mar 3, 2014, 8:45:10 PM3/3/14
to python_in...@googlegroups.com
Great, I think I got it working.  Thank you both!
Reply all
Reply to author
Forward
0 new messages