I am trying to import this camera animation information which was initially a .chan format from Nuke and imparts the information into the Maya camera, thus meaning to say, the Maya camera will works the same way as the one in the Nuke.
Currently I am having trouble to imports in the values of the nuke camera into maya camera. The following is importing dialog:
filters = "chan (*.chan)"
fileList = cmds.fileDialog2(fileMode=1, fileFilter=filters, dialogStyle=2)
with open (fileList[0], 'rt') as filehandle:
for line in filehandle:
print line
And this will displays the output aka. the information in the .chan file. It is following in this order: Frame, translateX, translateY, translateZ, rotateX, rotateY, rotateZ.
A small snippet of the output is as follows:
1 0 0 0 180 -0 0 39.2164
2 0.763887 0.0190331 -0.0218766 -178.268 -5.44147 -0.346042 39.2164
3 5.92473 0.344456 6.6543 17.5934 -74.886 168.27 39.2164
4 6.11879 0.30712 5.50863 79.2254 -87.0982 104.943 39.2164
I have tried changing my code in the latter part into this:
with open (fileList[0], 'rt') as filehandle:
rows = zip(*[line.split() for line in filehandle])
This is so that it will make ‘group’ the frames as well as both the translation and rotation values indivually for an ease of access.
However, if I tried to incorporate it into different functions for the frames and the trans/rot. values, I will be getting errors as follows:
cmds.currentTime(int(rows[0]), edit=True, update=False)
cmds.setKeyframe("camera1", attribute='translateX', v=float(row[1]))
# Error: float() argument must be a string or a number
# Traceback (most recent call last):
# File "<maya console>", line 1, in <module>
# TypeError: float() argument must be a string or a number #
Or there are times, it sort of worked but it is only keying in the animation at the last frame.
Perhaps are there any better ways to handle this?