I am trying to make a simple "allign tool" in maya using Python script, and this is how far I got
import maya.cmds as cmds
selected = cmds.ls(selection=True)
for all in selected:
cmds.getAttr('Cube.translateX')
And this seems to get the X position of the object names cube in the scene, However I would like it to get the translate of any object I selected.
I hope someone can help out, thanks
@kartikg's answer will work fine. As an alternative, maya's default behavior is to use selected objects by default for commands which need objects to work on. So:
This is useful when you want to do a series of commands on every object in the list, since you don't have to type the string formatter for every command. However @kartikg's method is easier to read and debug since you can check it by replace the command with a print statement.