-2

I am trying to create a function which allows me to zero out all of my transforms(scale, rotation, translation) I have found a way to code it in python but it seems to be a bit too much coding. I am wondering if there is any way to simplify this code?

# zero out transforms for 'pSphere1'
objName = 'pSphere1'
# set translate XYZ to 0
cmds.setAttr(objName + '.tx', 0)
cmds.setAttr(objName + '.ty', 0)
cmds.setAttr(objName + '.tz', 0)
# set rotate XYZ to 0
cmds.setAttr(objName + '.rx', 0)
cmds.setAttr(objName + '.ry', 0)
cmds.setAttr(objName + '.rz', 0)
# set scale XYZ to 1
cmds.setAttr(objName + '.sx', 1)
cmds.setAttr(objName + '.sy', 1)
cmds.setAttr(objName + '.sz', 1)

2 Answers2

2
cmds.makeIdentity("pSphere1", apply=False, t=True, r=True, s=True)
haggi krey
  • 1,885
  • 1
  • 7
  • 9
0

Just for the sake of completeness, and as an addition to @haggi-krev's answer, you could use xform to perform transforms:

cmds.xform('pSphere1', rotation=(0,0,0), translation=(0,0,0), scale=(1,1,1))

You can also slightly abbreviate your existing code like this:

cmds.setAttr('pSphere1.translate', 0, 0, 0)
cmds.setAttr('pSphere1.rotate', 0, 0, 0)
cmds.setAttr('pSphere1.scale', 1, 1, 1)
Daniel Skovli
  • 455
  • 3
  • 8