Okey. I am quite new to scripting in Maya but I try to make the best out of my limited knowledge.
I have a textfile that we get from unity with ~162000 frames that I want to import into Maya as keyframes. And it has worked great when it is files with around 50000 frames but when it increases the program it seems to use up all the memory So I would say that there is where the problem is. I have searched on google and found that I could use openMaya and use the api instead of cmds. But I have not been able to get it to work.
import maya.cmds as cmds
with open("C:\Textfiles\FacialData_Doctor(Clone)2001_Peter_fps40_2017-08-02_14-04-28.txt", 'r') as f:
for line in f:
framecount, blendshape, name, x = line.strip(" \t\r\n").split(",")
objectName = cmds.ls(name[10:] + "_Driver")
cmds.setKeyframe( objectName, time=int(framecount), attribute='translateX', value=float(x)/float(10)*float(3) )
This is how i do it now. It is slow but it works. Except for the problem above.
The lines in the text document looks like this:
where the lines are seperated with "," first comes framecount then miliseconds then name of the blendshape and then we have the translate X.
we have 23 blendshapes per frame.
Hopefully I am able to express my problem.