I'm currently making a script that will collect various user information from the scene and then write that information out to a file. I'm doing this by collecting all the information first into a single string variable. Once I've run through all of the loops I need and have all the information in my string I then dump that out into a file all at once. Like so
I'm doing it this way because I've heard that leaving the file open too long and having too many fprint commands will really bog things down.
So far this is working fine in all the tests I've tried. However i'm concerned that if a random user has too much information in their scene that i may overload the $fileContents string variable. or run into size limits with the fprint command.
Are these reasonable worries? Are there limits on variable size? If so has anyone come up against them and found workarounds?
How big is the string you're writing out generally? I've had strings upto around 50k in size with no problems at all. I know there's a 1k string limit when reading in from a text file with fread but I've never hit any size limit with fprint. I usually append to an output string during the file prep then dump the entire file out in 1 fprint.
That's kind of the problem. I don't know how large things will get. Effectively I'm writing out animation curves. The tests I've done so far have only gotten up to about 30k. But these are relatively simple animations. And I haven't run into any problems yet. While debugging things I actually had to insert a pause so I could make sure the progressBar was working. But size goes up with more objects exported in a single file and more keyframes per object. So conceivably these files could get quite large. I just want to plan for the future and for unknown users.
I guess I could do a size check on the string at each iteration and if it's above a certain limit write out that chunk. Then append the next chunk when it's ready. But how to know what limit to set? And multiple fopens and fcloses would slow things down. Maybe it just requires experimentation.
I'm not using fread so that shouldn't be a problem in this case. It's good to know about that limit though.
i've written an animation exporter as well that exports the file with a single fprint command as well. i've exported files up to about 300k without problem. i don't think there is really a size limit for the variables. well, other than standard hardware limits.
BTW, i just did a bit of a test with my animatino export script. it handled a 6.1meg file just fine. so there doesn't seem to be a practical limit. 6.1 megs equates to around 150 000 keyframes, which in practical terms, is probably around 2400-5000 frames of animation for a reasonably complex bipedal rig.
Cool. I think that sounds like more than a reasonable amount to data. It's good to know Maya can handle stuff like that. And I am familiar with your zooXferAnim script. Very nice.
hey, looks like a nice little script that you're writing there. i see you've got an absolute mode for writing. how are you doing that? the only way i could figure out to get absolute (i asume you mean world space when you say absolute) key values, was to step through each key in time, and do an xform -q -ws -rp on the object. which bugged me, simply because changing the time in maya forces a screem update (the -update false flag kept giving me incorrect values) which is slow.
i'd be interested to know how you're doing it. if you don't mind sharing.
I don't mind sharing as I do plan to release this script into the wild someday.
However I'm not using absolute the way you think. What I mean as absolute here is that the key values are pasted into the scene unchanged from when they were copied out. And the Relative switch will paste the values into an existing curve with the first pasted key having the current channel value. That way when you paste a curve it doesn't necisarrily create a discontinuity in the curve. Sort of like the difference between PostInfinity->Cylcle and PostInfinity->CycleWithOffset. Essentially I'm trying to recreate the options I found under Edit->Copy Curves.
Perhaps I should change the labeling on that switch.
Hmm,... pasting a curve with world space values. I think you're right, you would have to check the pivots on all of the animated nodes parent nodes for each key you set, in case one of the parent nodes was animated as well.
Well, now you've got me thinking about how to paste animation into world space, and no doubt this will consume my thoughts for many days. It'd be so simple if setKeyframe had a worldSpace switch or xform had a time switch.
well, see if the getAttr -time command worked properly, it'd be easy to do. you could just create a locator, parent constrain it to the object in question, and then just do a getAttr -time $keyTime ( $locator + ".t" )...
but alas, i can't seem to get reliable information out of getAttr -time... anyone else got any ideas?