Announcement

Collapse
No announcement yet.

Assign render engine through Python script - Rhino V-Ray

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Assign render engine through Python script - Rhino V-Ray

    Hello,

    I'd like to let a user choose a render engine (CPU, CUDA or RTX) through a Python script, with an Eto window. It is part of a batch export script of VRayScenes.
    I wrote the UI part with Eto with no problem (a RadioButtonList switching between the engines). But I'm not succeeding in linking the render engine to the buttons, I can't call the engine.
    I'm trying to use this: (found here)

    Code:
    import rhVRay as vray
    
    cudaDevices = vray.GetDeviceList(vray.RenderEngines.RE_CUDA)
    enabled = cudaDevices[0].UseForRendering
    or this:

    Code:
    import rhVRay as vray
    
    cudaDevices = vray.GetDeviceList(vray.RenderEngines.RE_CUDA)
    name = cudaDevices[0].Name
    I get the following error : Message: 'module' object has no attribute 'GetDeviceList'.
    Same thing to define the level of render quality : there are 6 levels in V-Ray UI (Low', 'Low+', 'Medium', 'Medium+', 'High', 'High+') but I don't find how to access them.

    I can't find anything on forums, any help will be appreciated ! (I started not long ago scripting in Rhino so I don't have a global vision of how it fully works)

    I work​ on:
    Rhino 6 SR35
    V-Ray 6 5.20.05
    Windows 11

    Thank you !

  • #2
    Ok, the issue was the version of V-Ray, the script works after the upgrade. My very bad !
    Guessing the command to set the render engine (to CUDA for example) is:
    Code:
    import rhVRay as vray
    
    vray.RenderEngines.RE_CUDA
    but not sure if it is really assigning the render engine.

    I know this exists:
    Code:
    vray.Render(renderEngine, renderMode, -1)
    But I don't want to render, I want to export vr_scenes, that's why I'd like to set the render engine, before exporting.

    I still can't find how to access though to the render quality. I understood through this post that it may be taken into account by the UI development team soon. Fingers crossed !
    Last edited by matferbourgeat_groupe; 11-07-2023, 09:33 AM.

    Comment


    • #3
      Hello matferbourgeat_groupe​,
      Thank you for writing us!

      1. Choosing a Render Engine is not in our documentation yet, but here is one proposal to do it.
      For setting the Render Engine to CUDA for example, you can use this Rhino Python 2 script:
      Code:
      import rhVRay as vray
      
      with vray.Scene.Transaction():
          vray.Scene.SettingsOptions.render_mode=4
      ​Here is a list of render modes:
      Code:
      enum RenderMode {
       RENDER_MODE_PRODUCTION = -1,
       RENDER_MODE_INTERACTIVE = 0,
       RENDER_MODE_INTERACTIVE_CUDA = 4,
       RENDER_MODE_INTERACTIVE_OPTIX = 7,
       RENDER_MODE_PRODUCTION_CUDA = 104,
       RENDER_MODE_PRODUCTION_OPTIX = 107,
      };
      After running the script, the change will be applied and visible in the V-Ray Asset Editor > Settings > Render.

      2. Here is an example of how to set the CUDA devices using GetDeviceList and SetDeviceList methods. (It is also similar to changing the RTX devices.) Short video here.

      Code:
      import System
      import rhVRay as vray
      
      def listme(devices):
       for device in devices:
        name = device.Name
        use = device.UseForRendering
      
        print("device name:" + name)
        print("use device:" + str(use))
      
      device_new=vray.RenderEngines.RE_CUDA
      cudaDevices = vray.GetDeviceList(device_new)
      listme(cudaDevices)
      
      vray.SetDeviceList(device_new, [0]) #set the devices - 0=CPU, 1=GPU CUDA...
      cudaDevices = vray.GetDeviceList(device_new)
      listme(cudaDevices)

      As a result, the first two "use device" lines show the existing device settings:
      Click image for larger version

Name:	existing.png
Views:	161
Size:	61.4 KB
ID:	1185864
      The last two "use device" lines show the new device settings:
      Click image for larger version

Name:	new_set_devices.png
Views:	168
Size:	53.5 KB
ID:	1185865

      3. About the script for the Render Quality - we will share here, as soon as there is some news.

      Kind regards,
      Ivelina
      Attached Files
      Ivelina Mincheva
      V-Ray for SketchUp | V-Ray for Rhino | QA
      www.chaos.com

      Comment


      • #4
        Thank you so much ivelina_mincheva !
        Everything's clear and perfectly operating.
        Can't wait for the news about Render quality scripting.

        Best regards,

        J.

        Comment

        Working...
        X