Outputting as a EXR through python.

Outputting as a EXR through python.

joe_jobson
Participant Participant
938 Views
1 Reply
Message 1 of 2

Outputting as a EXR through python.

joe_jobson
Participant
Participant

I want to output a file as a exr through the render settings for VRay. I have some code but I either get errors or it doesn't actually output anything once rendering. If you're able to help figure out why or how to properly set it up that would be great thank you!

 

    options = QFileDialog.Options()
    options |= QFileDialog.DontUseNativeDialog  # Optional: Use this if you don't want the native dialog

    file_dialog = QFileDialog()
    file_dialog.setWindowTitle("Choose save location")
    file_dialog.setAcceptMode(QFileDialog.AcceptSave)
    file_dialog.setNameFilter("EXR files (*.exr)")
    file_dialog.setDefaultSuffix("exr")
    file_location, _ = file_dialog.getSaveFileName(options=options)
    
    if file_location:
        if not file_location.endswith(".exr"):
            file_location += ".exr"
        print("Selected file location: ", file_location)

        rt = pymxs.runtime
        
        # Ensure we are using V-Ray renderer
        if rt.classof(rt.renderers.current) != rt.VRay:
            rt.renderers.current = rt.VRay()
        
        # Set the render output file
        rt.renderers.current.output_on = True
        rt.renderers.current.output_file = file_location
        rt.renderers.current.output_rawFileName = file_location

        # Configure EXR settings using setOption method
        rt.renderers.current.output_saveRawFile = True
        rt.renderers.current.output_rawFileType = 1  # EXR
        rt.renderers.current.output_exr_compression = 3  # ZIPS compression
        rt.renderers.current.output_exr_bitsPerChannel = 16  # 16-bit EXR
        rt.renderers.current.output_exr_autoDataWindow = True
        rt.renderers.current.output_exr_applyColorMapping = True

        # Print settings to verify (for debugging purposes)
        print("Output File:", rt.renderers.current.output_rawFileName)
        print("EXR Compression:", rt.renderers.current.output_exr_compression)
        print("EXR Bits per Channel:", rt.renderers.current.output_exr_bitsPerChannel)

        # Initiate the render process
        rt.renderScene()
    else:
        print("No file selected")

 

0 Likes
939 Views
1 Reply
Reply (1)
Message 2 of 2

denisT.MaxDoctor
Advisor
Advisor

And what is the request? Sympathy?  😉

0 Likes