Python / Maya .write question
Posted in: Maya# Error: argument 1 must be string or read-only character buffer, not list
Here is the code:
import maya.cmds as mc
myFileObject=open('/data/keyFrames.txt', 'w')
obs = mc.ls(sl=True)
myY = []
for selection in obs:
myAtF = mc.getAttr(selection + '.ty')
myAt = str(myAtF)
myY.append(myAt +'\n')
myFileObject.write(myY)
myFileObject.close()
I guess the problem lies here:
myFileObject.write(myY)
I need to know how to convert myY ([‘1.32054365278\n’, ‘9.59632723791\n’, ‘5.49012983596\n’]), which is a list, to a string?
What I am trying to end up with raw values, formatted like below, in a text file.
1.32054365278
9.59632723791
5.49012983596
These are the y translate values of three selected spheres, just for example.
Post a Comment