Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8231789
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T17:36:47+00:00 2026-06-07T17:36:47+00:00

This may be a simple task but at the moment I really have no

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T17:36:49+00:00Added an answer on June 7, 2026 at 5:36 pm

    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.

    #include <fstream>
    #include <iostream>
    #include <vector>
    
    bool Convert(const char* InputFilename, const char* OutputFilename)
    {
        std::ifstream InFile(InputFilename);
        if(!InFile)
        {
            std::cout << "Could not open  input file '" << InputFilename << "'" << std::endl;
            return false;
        }
    
        struct PositionData
        {
            double FrameNum;
            double X;
            double Y;
            double Z;
        };
        typedef std::vector<PositionData> PositionVec;
    
        PositionVec Positions;
        PositionData Pos;
        while(InFile)
        {
            InFile >> Pos.FrameNum >> Pos.X >> Pos.Y >> Pos.Z;
            Positions.push_back(Pos);
        }
    
        std::ofstream OutFile(OutputFilename);
        if(!OutFile)
        {
            std::cout << "Could not open output file '" << OutputFilename << "'" << std::endl;
            return false;
        }
    
        OutFile << "Transform\tPosition\n\tFrame\tX pixels\tY pixels\tZ pixels" << std::endl;
        for(PositionVec::iterator it = Positions.begin(); it != Positions.end(); ++it)
        {
            const PositionData& p(*it);
            OutFile << "\t" << p.FrameNum << "\t" << p.X << "\t" << p.Y << "\t" << p.Z << std::endl;
        }
        OutFile << "End of Keyframe Data" << std::endl;
        return true;
    }
    
    int main(int argc, char* argv[])
    {
        if(argc < 3)
        {
            std::cout << "Usage: convert <input filename> <output filename>" << std::endl;
            return 0;
        }
        bool Success = Convert(argv[1], argv[2]);
    
        return Success;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This seems like a simple task but there may be an easier way. I
this may be stupidly simple but I'm trying to figure out a way to
Okay this may be a simple question but I have yet to come with
This may be a simple question but I can;t find the answer anywhere. Here
This may be a simple fix and maybe I'm missing something obvious, but when
This may well be simple, but I'm new to Drupal. The organization I work
This may be very simple question,But please help me. i wanted to know what
This may be a simple answer, but I'm trying to add a dom-created element
This may be super simple - but I'm struggling to spot what's going on.
Okay, This may be really simple or it may not even be possible, or

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.