Hi Teddy, yes there is a way for a script to read and write to a text file. This is done with moi.filesystem.openFileStream( filename, mode ).
moi.filesystem.openFileStream takes 2 parameters, a file name and the mode which is either 'r' for read or 'w' for write. Check out the updated version of SavePointFile (the one that says it works on Mac) for an example: http://kyticka.webzdarma.cz/3d/moi/#SavePointFile .
The Filestream object has these functions:
.readLine() - reads a line of text from the stream, the text is the return value of the function.
.writeLine( text ) - writes a line of text to the stream.
.atEOF property - returns true if the stream is at the end with nothing more to read from it.
.close() - closes the stream.
.setWriteBOM( ) - sets whether to write the byte order mark at the front of the text file, default is no BOM.
.setCodec( name ) - controls the encoding to use for reading or writing. Supported codecs are listed here: http://doc.qt.io/qt-5/qtextcodec.html#details .
> Q: is there a way to embed data such as the array of saved views directly into a 3DM file?
Sorry, no - currently there isn't really a proper way for a script to embed its own data into a 3DM file.
- Michael
|