This may be a simple task but at the moment I really have no clue how I could do this in a simple way.
I have the following situation, I have a script written in COFFEE, the scripting language of the 3D program Cinema 4D.
Now this script is writing position data in the following format into a text file (rtf in that case but can be a .txt aswell).
0 0.0 471.2 0.0
1 0.0 470.5 0.0
2 0.0 468.8 0.0
3 0.0 465.9 0.0
4 0.0 461.9 0.0
5 0.0 456.8 0.0
6 0.0 450.5 0.0
7 0.0 443.2 0.0
8 0.0 434.8 0.0
9 0.0 425.2 0.0
Frame, X, Y, Z.
Now what I need to do is getting this position data into this format:
Transform Position
Frame X pixels Y pixels Z pixels
0 0.0 471.2 0.0
1 0.0 470.5 0.0
2 0.0 468.8 0.0
End of Keyframe Data
It is not really visible here but there are no spaces in here, everything is spaced with tab (maybe copy that to notepad to really see the tabs). It’s important that I have tabs between every number, there can be spaces but I need exactly one tab character everytime.
So the most important part is, how do I get those numbers from the first data set and bring and let the program add a \t between every number?
I tried to do this within the script but the script fails if I use a tab instead of several spaces between my positions.
I searched quite a lot but couldn’t find any good solution for this.
I’m familiar with C++ and a little batch script but I’m happy for every solution even if I have to learn the basics of another language.
I tried to find a way in C++ but no way that I came up with could format an n number of lines and every single one was way to complicated. The number of frames/lines varies everytime so I never have a fixed line count.
Something like this might work. I didn’t do any special formatting of the numbers, so if you need that you’ll need to add it. If you’re worried about a malformed input file, like not enough numbers on a line then you’d want to add some additional error checking to guard against it.