Changing OCIO View Transform doesn't work using Python
-
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()
-
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 -
Thank you @ferdinand for answer. Yes, most of the code is from chat but when I create Xpresso python it shows this command :
-
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