On 28/02/2018 at 05:16, xxxxxxxx wrote:
I have written a SceneSaverData to export documents to a new format. It works just file, no problems there. I can also use c4d.documents.SaveDocument(doc, filename, c4d.SAVEDOCUMENTFLAGS_EXPORTDIALOG|c4d.SAVEDOCUMENTFLAGS_DIALOGSALLOWED, mySceneSaversPluginId) from e.g. a Python Script to start the document export. No problems either.
But here it comes: In the Python documentations, it states:
_<_dt id="c4d.s.save" style=": rgb55, 5, 82; color: white;"_>_c4d.documents.SaveDocument(doc, name, saveflags, format)
Saves the document to a file.
The script that shows how to effectively access and change the settings of an importer/exporter.
Warning note in SceneSaverData.Save().
But when I do something like this in a script:
** mfs = c4d.storage.MemoryFileStruct()**
** result = c4d.documents.SaveDocument(doc, mfs, c4d.SAVEDOCUMENTFLAGS_EXPORTDIALOG|c4d.SAVEDOCUMENTFLAGS_DIALOGSALLOWED|c4d.SAVEDOCUMENTFLAGS_DONTADDTORECENTLIST, ID_MYSCENESAVERDATA)**
...I always get a string as the name argument in my SceneSaverData's Save() method, and the string only contains "mfs:///". Of course, that's not a valid filename, so I can't create a file at that location.
Long story short:
Should I not get the MemoryFileStruct object as name?
How can I support the usage of a MemoryFileStruct in my own SceneSaverData?
Thanks in advance for any help!
On 01/03/2018 at 01:30, xxxxxxxx wrote:
typically within Cinema 4D a file is not created directly but with helper classes like BaseFile or HyperFile. BaseFile::Open() can open and write into a Filename element referencing a MemoryFileStruct.
So within a C++ SceneSaverData plugin you could support a MemoryFileStruct target by using BaseFile to write the file. Unfortunately BaseFile is not available in Python, only HyperFile is. So I'm afraid it is currently not possible to support this specific scenario in Python plugins.
See also BaseFile Manual and MemoryFileStruct Manual.