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

**URL:** <https://forums.chaos.com/t/assign-render-engine-through-python-script-rhino-v-ray/115732>\
**Category:** Issues\
**Created:** [July 10, 2023, 3:28pm UTC](https://forums.chaos.com/t/assign-render-engine-through-python-script-rhino-v-ray/115732 "2023-07-10T15:28:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![matferbourgeat\_groupe](https://avatars.discourse-cdn.com/v4/letter/m/838e76/32.png) [@matferbourgeat\_groupe](https://forums.chaos.com/u/matferbourgeat_groupe)\
**Post date:** [July 10, 2023, 3:28pm UTC](https://forums.chaos.com/t/assign-render-engine-through-python-script-rhino-v-ray/115732/1 "2023-07-10T15:28:38Z")

</div>

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](https://docs.chaos.com/display/VRHINO/V-Ray+Script+Access))

```auto

import rhVRay as vray

cudaDevices = vray.GetDeviceList(vray.RenderEngines.RE_CUDA)
enabled = cudaDevices[0].UseForRendering

```

or this:

```auto

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 !

---

<div class="post-metadata">

**Author:** ![matferbourgeat\_groupe](https://avatars.discourse-cdn.com/v4/letter/m/838e76/32.png) [@matferbourgeat\_groupe](https://forums.chaos.com/u/matferbourgeat_groupe)\
**Post date:** [July 11, 2023, 10:00am UTC](https://forums.chaos.com/t/assign-render-engine-through-python-script-rhino-v-ray/115732/2 "2023-07-11T10:00:16Z")

</div>

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:

```auto

import rhVRay as vray

vray.RenderEngines.RE_CUDA

```

but not sure if it is really assigning the render engine.

I know this exists:

```auto

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](https://forums.chaos.com/forum/v-ray-for-rhino-forums/v-ray-for-rhino-general/1175788-advanced-v-ray-python-scripting-questions)that it may be taken into account by the UI development team soon. Fingers crossed !

---

<div class="post-metadata">

**Author:** ![ivelina\_mincheva](https://dub1.discourse-cdn.com/chaosprd/user_avatar/forums.chaos.com/ivelina_mincheva/32/54117_2.png) [@ivelina\_mincheva](https://forums.chaos.com/u/ivelina_mincheva)\
**Post date:** [July 12, 2023, 2:42pm UTC](https://forums.chaos.com/t/assign-render-engine-through-python-script-rhino-v-ray/115732/3 "2023-07-12T14:42:06Z")

</div>

Hello [matferbourgeat\_groupe](https://forums.chaos.com/member/283435-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:

```auto
import rhVRay as vray

with vray.Scene.Transaction():
    vray.Scene.SettingsOptions.render_mode=4

```

​Here is a list of render modes:

```auto
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](http://ftp.chaosgroup.com/support/scenes/Get_and_SetDeviceList-example.mp4).

````auto
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:
![existing.png|978x289](upload://7l18Cm3P1ydxz6pj4FXzAmDP54M.png)
The last two "use device" lines show the new device settings:
![new_set_devices.png|976x284](upload://sZnVaVSVdEyWj3jnOnpkpCx1WJy.png)

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

Kind regards,
Ivelina
​
![new_set_devices.png|976x284](upload://sZnVaVSVdEyWj3jnOnpkpCx1WJy.png)
![existing.png|978x289](upload://7l18Cm3P1ydxz6pj4FXzAmDP54M.png)
````

---

<div class="post-metadata">

**Author:** ![matferbourgeat\_groupe](https://avatars.discourse-cdn.com/v4/letter/m/838e76/32.png) [@matferbourgeat\_groupe](https://forums.chaos.com/u/matferbourgeat_groupe)\
**Post date:** [July 12, 2023, 3:06pm UTC](https://forums.chaos.com/t/assign-render-engine-through-python-script-rhino-v-ray/115732/4 "2023-07-12T15:06:18Z")

</div>

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.
