Hi Serena,
The first and most important reason that its not working as expected is that while you are looping over the iterator, you aren't using it to get the current object. Instead, you are accessing the original selection list each time with the same 0 index. You should change that line to:
iter1.getDagPath(dagPath)
Note that I removed the cube object because you never use it. There were some other things I saw too but I might just be using it differently than you intended...
It was crashing for me while trying to rotate and transform on shape nodes as opposed to transform notes, because your selection filter "geometric" was causing it to return shapes. I removed the filter for now. Also, it crashed doing the rotate because seRotation() was expecting a Quaternion type instead of a EulerRotation. You can call asQuaternion() for that part.
You have a pretty generic nested try-except block in there which can make debugging very difficult. Its best not to wrap blanket statement exception handling around code because you might miss unexpected errors and completely mask them.
And the last comment I have is more of a performance thing. There are a few lines you can move outside the while loop and only create them once. This could help if you had a very large selection list to loop over and you were concerned with speed.
Here is the modified moveCubes() function. I will include it here and a pastebin in case its not readable:
# removed the geometric filter for now
iter1 = om.MItSelectionList( sList )
# creating all of these once to reuse
dagPath = om.MDagPath()
transFn = om.MFnTransform()
spc = om.MSpace.kWorld
ord = om.MEulerRotation.kXYZ
while not iter1.isDone():
# 1. removed the cube ref, as its never used
# 2. use the iter1 to get the dagPath instead of
# calling it on the sList
iter1.getDagPath(dagPath)
# reuse the fn by settings the new dagPath object
transFn.setObject(dagPath)
try:
transFn.setTranslation(vector, spc)
# convert Euler -> Quaternion as required by API
transFn.setRotation(rot.asQuaternion(), spc)
except Exception, e:
# at least logging the exception as well
sys.stderr.write("Error doing translate on transform\n%s" % e)
# always calling next(), and only in one place
iter1.next()
I didn't move the rotation and vector function calls outside of the for loop because even though you are using the same value each time, I expect that you will be doing something to probably vary that in each loop.
Hope that help!
-- justin