I’m working with pymel and am trying to spread selected object inside the range of 10 units.
def spread(): selList = pm.ls(sl=True) for obj in selList: rangeX = random.randint(-10, 10) rangeZ = random.randint(-10, 10) obj.translateBy((rangeX, 0, rangeZ))
This works but it’s relative to current translate of the object. Suppose if I run this function 5 times, each time it would calculate the 10 unit translate from the current position it is moved.
Previously, I was working with maya.cmds and used
setAttr for translation of the object, and it worked fine.
setAttr(obj + ".translateX", rangeX)
But now I want to use pymel; for sake of it’s pythonic-ness.