Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware 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

    How to change the EXR compression method via python

    Cineware SDK
    3
    7
    2.6k
    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.
    • P
      pyr
      last edited by m_adam

      I need to change my exr compression to one scanline at a time but beside using a c4d default document is there any other way to change it directly in a script?

      1 Reply Last reply Reply Quote 0
      • M
        mp5gosu
        last edited by

        Here you go: https://github.com/PluginCafe/cinema4d_py_sdk_extended/blob/762c9d505e0ed2f09dafdd8c6cef972a82d084e8/scripts/04_3d_concepts/rendering/render_settings_openexr_data_r20.py

        1 Reply Last reply Reply Quote 1
        • P
          pyr
          last edited by

          The script change the compression method to zip not to Zips or what i expected: RLE because rle was the given value.

          1 Reply Last reply Reply Quote 0
          • M
            mp5gosu
            last edited by mp5gosu

            Oh yes, you are right. The SDK example doesn't work at all.
            Problem is, maxon.Id is wrong. maxon.InternedId would be the correct way for setting the save options. Here's the correct code:

            """
            Copyright: MAXON Computer GmbH
            Author: Maxime Adam
            Description:
                - Configures OpenEXR output render format with SetImageSettingsDictionary() then reads these with GetImageSettingsDictionary().
            Class/method highlighted:
                - c4d.bitmaps.SetImageSettingsDictionary()
                - c4d.bitmaps.GetImageSettingsDictionary()
            Compatible:
                - Win / Mac
                - R20, R21, S22, R23
            """
            import c4d
            import maxon
            
            
            def main():
                # Retrieves render data and its container
                renderData = doc.GetActiveRenderData()
                bc = renderData.GetDataInstance()
            
                # Gets image filters options
                saveOptions = bc.GetContainerInstance(c4d.RDATA_SAVEOPTIONS)
            
                # Sets OpenEXR output format
                bc[c4d.RDATA_FORMAT] = c4d.FILTER_EXR
            
                # Defines OpenEXR settings
                compressionmethodID = maxon.InternedId('net.maxon.mediasession.openexr.export.compressionmethod')
                halffloatID = maxon.InternedId('net.maxon.mediasession.openexr.export.halffloat')
                layernumberingID = maxon.InternedId('net.maxon.mediasession.openexr.export.layernumbering')
            
                # Configures OpenEXR format options with a maxon.DataDictionary
                exportSettings = maxon.DataDictionary()
                exportSettings.Set(compressionmethodID, maxon.Id("rle"))
                exportSettings.Set(halffloatID, True)
                exportSettings.Set(layernumberingID, True)
            
                # Stores settings in render data container
                c4d.bitmaps.SetImageSettingsDictionary(exportSettings, saveOptions, c4d.FILTER_EXR)
            
                # Pushes an update event to Cinema 4D
                c4d.EventAdd()
            
                # Retrieves OpenEXR images settings
                settings = c4d.bitmaps.GetImageSettingsDictionary(saveOptions, c4d.FILTER_EXR)
            
                # Reads and prints OpenEXR format options
                print("openexr.export.compressionmethod: " + str(settings.Get(compressionmethodID)))
                print("openexr.export.halffloat: " + str(settings.Get(halffloatID)))
                print("openexr.export.layernumbering: " + str(settings.Get(layernumberingID)))
            
            
            if __name__ == '__main__':
                main()
            
            1 Reply Last reply Reply Quote 2
            • M
              mp5gosu
              last edited by

              @m_adam maybe the code example in the repo should be updated. 😉

              1 Reply Last reply Reply Quote 0
              • P
                pyr
                last edited by pyr

                <3<3<3<3

                1 Reply Last reply Reply Quote 0
                • M
                  m_adam
                  last edited by

                  Thanks a lot for the update and yes maxon.InternedId should be used instead of maxon.Id.
                  I will take care of updating the example in Github.
                  Cheers,
                  Maxime.

                  MAXON SDK Specialist

                  Development Blog, MAXON Registered Developer

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