Finding and setting global transform values in Pymel

1,010 views
Skip to first unread message

Chad_Fox

unread,
Apr 12, 2011, 10:35:56 PM4/12/11
to python_inside_maya
Hi all,

I'm having difficulty figuring out how to get and set transform values
in world space using pymel. Maybe I'm searching for the wrong terms in
the docs and google, but so far no luck in figuring this out. If you
know how to do this I would love to hear from you.

Thank you,

Chad

John Patrick

unread,
Apr 14, 2011, 1:37:11 AM4/14/11
to python_in...@googlegroups.com
import pymel.core as pm
s  = pm.sphere()[0]
g = pm.group()
g.t.set([5,5,5]) #this is how you set attributes on the node.  In this case I'm setting the compound translate attr, called by its short name

#other methods are bound to the object from functions available via the Python API, such as 'setTranslation'
#note the relationship of PyMel node types to corresponding MFn classes: #http://download.autodesk.com/global/docs/mayasdk2012/en_us/index.html

help(s.setTranslation) # use this to see the kwargs available

#set to 5,5,5 in world space.  In other words, don't move it
s.setTranslation([5,5,5], space='world')
s.t.get() #

#compare this to the following

s.setTranslation([5,5,5], space='object')

s.t.get()


#Have fun! -JP


Reply all
Reply to author
Forward
0 new messages