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

    Suggested way to handle parameter changes

    SDK Help
    0
    3
    283
    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
      Helper
      last edited by

      On 08/07/2013 at 03:27, xxxxxxxx wrote:

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

      ---------
      Hi!

      In our latest release we replaced some parameters by a single parameter (custom datatype). My question is what is the suggested way to handle such parameter changes to maintain backward and also forward compability (loading of objects saved with old plugin).
      Currently I do it like this:
      When the latest version of the plugin is loaded I use Read() to set the new parameter by reading the old parameters. Then if the value of the new parameter changes I use SetDParameter() to also set the old parameters to maintain backward compability. Does anyone have a cleaner solution?

      Thanks!
      Satara

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

        On 08/07/2013 at 03:40, xxxxxxxx wrote:

        If you want the old plugin to load scens saved with the new plugin, you must convert the new data
        format to the old format when writing to file. When reading, you simply convert it to the new format
        and set it to your parameter.

        I doubt there's a better solution to this. You'll break the beakwards compatibility in any other case.
        Though, if your new parameter contains _additional_ information, you must write this information
        on another disklevel.

        I'm not sure how Cinema handles the loading of the value from the file since they are written
        and loaded automatically so you can not interferre and tell Cinema "wait a sec, that value you
        wrote automatically the last time, I want to read it myself this time" or something like this. My
        guess is that the value is automatically read and loaded into the container. You could just retrieve
        the loaded information, convert it to your new parameter and delete the old information from the
        container.

        For writing, you need to do the whole thing backwards. So you just fill in the original container IDs
        with the values in the old data format and let Cinema automatically write your container. Only
        question remaining is _when_ you can do that.. 🙂

        Best,
        -Nik

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

          On 08/07/2013 at 04:06, xxxxxxxx wrote:

          Hey Niklas, thanks for the quick response!
          I already tried it like this but as you say the problem is "when" to set the old parameters. While reading of the old parameters works fine, setting of the parameters in Write() does not work.
          So I assume when Read() gets called the original BaseContainer is already restored. But it seems to be saved before Write() gets called.

          I just checked the docs again and noticed that the DocumentInfoData struct which is passed with MSG_DOCUMENTINFO defines Events like MSG_DOCUMENTINFO_TYPE_SAVE_AFTER and MSG_DOCUMENTINFO_TYPE_LOAD. I think I could use those instead of Read() and Write(). Thanks again for the hint!

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