I’ve been meaning to ask some of these questions for quite some time. I rely heavily on scripted Rhino and V-Ray to automate as much as possible. A few things I’ve never been able to figure out are:
- How to change the GPU devices programmatically via Python in Rhino and V-Ray. In the system service I wrote in Powershell that batch renders vrscenes for us automatically when they appear in a monitored folder, I had no issue selecting the GPU device by simply adjusting the environment variable
$env:VRAY_GPU_PLATFORMS = $DEVICE_MAP[$device]before vray.exe is invoked. In Rhino Python, I’ve tried editing the environment variables as well but nothing changes in the Asset Editor. I haven’t gone as far as trying to change the default renderer back to Rhino and then back again to V-Ray but I have triedvray.RefreshUI()of course and that didn’t work.
Any ideas? Here’s what I tried when I last attempted to figure this out a while ago:
```
print(os.environ['VRAY_GPU_PLATFORMS'])
os.environ['VRAY_GPU_PLATFORMS'] = "nvidia cuda nvidia geforce rtx 3080 ti gpu index0;nvidia cuda nvidia geforce rtx 3080 ti gpu index1;"
print(os.environ['VRAY_GPU_PLATFORMS'])
vray.RefreshUI()
1. Is it possible to adjust the rendering quality slider in the asset editor via Python so that I can render lower quality preview renders and switch to high quality production renders without having to manually intervene. I know I could save a low quality version of the VROPTS and a separate high quality one but what I REALLY want to know how to do is adjust the quality on-demand via Python.
When I adjust the SettingsOptions quality\_preset parameter, the quality slider in the Asset Editor changes but none of the other things like Noise Limit, Max Subdivs, etc actually change. I know that there are sometimes other related parameters that have to be adjusted for a change to take effect but I can't find anything else that's obvious between the vrscene and vropt files I've inspected. What am I missing?
```
vray2.Scene.Plugin('SettingsOptions').Param('quali ty_preset').Value = 2
vray.RefreshUI()
- Is there an easier way to calculate the transforms for rotating bitmaps programmatically in V-Ray? I resorted to building my own lookup dictionary after going through rotations at 5 degree intervals because I otherwise had no idea how to come up with the numbers I would need to pass in order to rotate a bitmap 30 degrees horizontally and 15 degrees vertically for example. Here’s a small chunk of my manually compiled lookup table looks like:
TRANSFORMS = { 'H000V000': (1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0), 'H-010V000': (0.984808, 0.173648, 0.0, -0.173648, 0.984808, 0.0, 0.0, 0.0, 1.0), 'H-015V000': (0.965926, 0.258819, 0.0, -0.258819, 0.965926, 0.0, 0.0, 0.0, 1.0), 'H-020V000': (0.939693, 0.34202, 0.0, -0.34202, 0.939693, 0.0, 0.0, 0.0, 1.0), 'H-030V000': (0.866025, 0.5, 0.0, -0.5, 0.866025, 0.0, 0.0, 0.0, 1.0), 'H-040V000': (0.766044, 0.642788, 0.0, -0.642788, 0.766044, 0.0, 0.0, 0.0, 1.0), 'H-045V000': (0.707107, 0.707107, 0.0, -0.707107, 0.707107, 0.0, 0.0, 0.0, 1.0), 'H-050V000': (0.642788, 0.766044, 0.0, -0.766044, 0.642788, 0.0, 0.0, 0.0, 1.0), ... }
I compiled this lookup table manually but I'd love to get rid of it if there's a way to generate those matrix transformations using a formula or 3rd party library that can help.