Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    SceneSaverData, SaveDocument(), MemoryFileStruct

    Scheduled Pinned Locked Moved PYTHON Development
    2 Posts 0 Posters 405 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H Offline
      Helper
      last edited by

      On 28/02/2018 at 05:16, xxxxxxxx wrote:

      Hi there,

      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.
      See also
       
      The script that shows how to effectively access and change the settings of an importer/exporter.
      See also
       
      Warning note in SceneSaverData.Save().
      Parameters:|

      • doc  (c4d.documents.BaseDocument) – Command ID
      • name  (str or MemoryFileStruct) – File to save the document to.

      <_<_t_>_

      But when I do something like this in a script:

      **    mfs = c4d.storage.MemoryFileStruct()**
      **    mfs.SetMemoryWriteMode()**
      **    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!

      Cheers,
      Frank

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        On 01/03/2018 at 01:30, xxxxxxxx wrote:

        Hello,

        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.

        best wishes,
        Sebastian

        1 Reply Last reply Reply Quote 0
        • First post
          Last post