Creating a text file



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 27/05/2003 at 11:12, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:   6.3 
    Platform:   Windows  ;   
    Language(s) :     C++  ;

    ---------
    I know this is a simple question. I am porting a plugin I worte to C++. It requires the writing of a text file. Whenever I try to create the file in C++ and write data to it, it is a binary file, not a text file.
     
    How can I write a text file from a Menu plugin?
    Thanks,
    Matt



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 27/05/2003 at 23:54, xxxxxxxx wrote:

    Use WriteBytes() instead of the formatted convenience functions. You can get a text buffer from String::GetCString().



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 28/05/2003 at 09:04, xxxxxxxx wrote:

    Now you had to know this was coming.... :)
    Im not very familiar with C++. I wrote a plugin in COFFEE and am trying to 'port' it to C++.  Can you give me a small example that will write a given string to a text file. Here is a sample of what I did in COFFEE:

        
        
        
        
        //RIB Header  
         file->WriteString("#RIB Export from Cinema 4D\n");  
           
         //Frame Begin  
         file->WriteString("FrameBegin 1\n");  
           
         //Image Options  
         file->WriteString("#Image options\n");  
         file->WriteString("Display \"test.tif\" \"file\" \"rgb\"\n");  
         file->WriteString("Display \"+test.tif\" \"framebuffer\" \"rgb\"\n");  
         file->WriteString("Format 640 480 1\n");  
         file->WriteString("Exposure 1.0 1.0\n");  
         file->WriteString("Quantize \"rgb\" 255 0 255 0.5\n");  
         file->WriteString("PixelSamples 2 2\n");  
         file->WriteString("PixelFilter \"gaussian\" 2 2\n");  
           
         //Camera Options  
         file->WriteString("#Camera options\n");  
         file->WriteString("Projection \"perspective\" \"fov\" [53.13]\n");
        
        
        
    

    Most of the time I am reading data from the objects in the scene to write to a RIB file, but these are just static values.
    Matt



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 28/05/2003 at 09:58, xxxxxxxx wrote:

    I looked up the definition of WriteString in the API files. It looks like it is doing the same thing you told me to do manually. (It uses WriteBytes and GetCString, etc) The only thing is that it adds the length before the string. I created another funciton, WriteText, that just uses WriteBytes. However, it is still producing binary files, not text files.
     
    Any other ideas?



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 01/06/2003 at 10:41, xxxxxxxx wrote:

    What do you mean by a binary file and a text file in this context?



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 02/06/2003 at 14:48, xxxxxxxx wrote:

    Well, I am trying to write out Renderman RIB files. They need to be standard text files that you could read in notepad for example. When I tried writing out the file, notepad or the Renderman renderer would let mek now that the file was not a text file, but a binary file.
     
    I did manage to get it working, but I used some standard C++ functions (fstream.h) to writet he files, but I fear it won't be very portable to the mac :(
     
    Matt


Log in to reply