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:
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?
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().
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:
file->WriteString("#RIB Export from Cinema 4D\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");
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.
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?
On 01/06/2003 at 10:41, xxxxxxxx wrote:
What do you mean by a binary file and a text file in this context?
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