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

    Changing OCIO View Transform doesn't work using Python

    Cinema 4D SDK
    python 2025
    2
    4
    516
    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.
    • S
      Smolak
      last edited by Smolak

      It looks like changing OCIO View Transform doesn't work using Python

      import c4d
      import maxon
      
      def main():
          # Get the active document
          doc = c4d.documents.GetActiveDocument()
          if not doc:
              print("No active document found")
              return
      
          # Create a new OCIO Config object
          ocio_config = maxon.c4d.documents.OpenColorIOConfig()
      
          # Load the OCIO configuration file (replace with your actual path)
          ocio_config_path = "$OCIO"
          result = ocio_config.Load(ocio_config_path)
          if result != c4d.OPEN_COLOR_IO_OK:
              print("Error loading OCIO configuration")
              return
      
          # Set the OCIO view transform
          ocio_view_transform = "3"  # Replace with your desired view transform
          ocio_config.SetViewTransform(ocio_view_transform)
      
          # Apply the OCIO configuration to the current document
          doc.SetOcioConfig(ocio_config)
      
          c4d.EventAdd()
      
      # Only execute the main function if the script is run directly
      if __name__ == '__main__':
          main()
      
      

      This simple version doesn't work too :

      import c4d
      
      def main():
          # Get the active document
          doc = c4d.documents.GetActiveDocument()
          if not doc:
              print("No active document found")
              return
      
          # Set the OCIO view transform
          view_transform = "3"  # Replace with your desired view transform
          doc[c4d.DOCUMENT_OCIO_VIEW_TRANSFORM] = view_transform
      
          c4d.EventAdd()
      
      if __name__ == "__main__":
          main()
      

      Architectural Visualizations - www.archviz-4d.studio

      ferdinandF 1 Reply Last reply Reply Quote 0
      • ferdinandF
        ferdinand @Smolak
        last edited by

        Hey @Smolak,

        Thank you for reaching out to us. I assume your code came from a chat bot, because pretty much every line in it is hallucinated. The Python API currently has no OCIO API, only C++ has (and it does not work like what your code shows).

        We are currently working on the Python OCIO API, which will then also allow you to set the view transform of a document. It will shipped with a future version of Cinema 4D, but as always, we cannot give out more concrete information about a when. But it will be quite soon.

        Cheers,
        Ferdinand

        MAXON SDK Specialist
        developers.maxon.net

        1 Reply Last reply Reply Quote 0
        • S
          Smolak
          last edited by

          Thank you @ferdinand for answer. Yes, most of the code is from chat but when I create Xpresso python it shows this command :

          image.png

          Architectural Visualizations - www.archviz-4d.studio

          ferdinandF 1 Reply Last reply Reply Quote 0
          • ferdinandF
            ferdinand @Smolak
            last edited by ferdinand

            Hey @Smolak,

            I understood what you wanted to do, but it is still not possible. First of all, the OCIO color space enum values are dynamically assigned, i.e., the value 3 might not always mean the same space. In the OCIO API there are special conversion functions for that, but you could also do that manually by parsing the description of the document.

            But you will never be able to apply such value then, because to do that, you have to call BaseDocument::UpdateOcioColorSpaces which does not exist in Python (yet). See the C++ Docs for an example.

            Cheers,
            Ferdinand

            MAXON SDK Specialist
            developers.maxon.net

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