Access VRay in C# script in Rhino/Grasshopper

Hi,

I’m trying to access vray functionality in a C# plugin in Grasshopper. I’ve seen several examples that do this in VB, such as:

Dim VRay
Set VRay = Rhino.GetPluginObject(“V-Ray for Rhino”)
VRay.SetAdaptiveDMCNoiseThreshold(0.1)

What would the equivalent be in C#?
I guess basically my question is what type should the variable “VRay” be so that I can access the v-ray functions in my code.

@littlecheese

Which features from V-Ray are you trying to script from Grasshopper?

Most of them. I’m basically writing a script that generates a 3D scene. I would then like to assign existing Vray materials to different entities in the scene, and possibly modify the material parameters. I would also like to create Vray light sources within the script, modify the camera, adapt rendering parameters, trigger the rendering, etc. Thanks for your help, this is highly appreciated!

Lil’ Cheese,
Did you ever figure this out at all? I thought maybe the Rhino document data would have it. No dice.
I’m trying to access through Python. I just want to be able to toggle 'batch render" on. :confused:
Thanks,
Chris

Another year later and I as well am looking for an answer to this. We are attempting to set up a render service for our office. To do this we are centralizing our materials database and want to be able to import materials (available via scripting) but also export materials back to .vrmat format to update the ‘global’ definitions. It would also be helpful to be able to interact with the vray render settings, modify lights and cameras, and assign vray materials to layers and objects outside of using a bunch of RhinoApp.RunScript(“foo”) lines.

Any help would be appreciated.

Hi @diana_lp,

The V-Ray folks will never see your post in this category - you might want to move it to the Rendering > VRay category.

https://discourse.mcneel.com/c/rendering/v-ray

– Dale

1 Like

Note that VRay does actually come with “a .NET interface dll in C:\ProgramData\ASGVIS\VfR564\VRayForRhinoNETInterface.dll” outside of scripting macros, more here:

I don’t have this ASGVIS folder in my ProgramData directory - am I missing a setting during the installation?

I think you might be able to obtain a copy of that dll from this location for version 3.6

C:\Program Files\Chaos Group\V-Ray\V-Ray for Rhinoceros 5\GrasshopperComponents\VRayForRhinoNETInterface.dll

1 Like

Failing that, try to search your system for VRayForRhinoNETInterface using Everything.

This worked! For anyone in the future: I had to install V-Ray for Rhino 5 (previously had only 6) and it was in this directory that @Trav mentioned:

C:\Program Files\Chaos Group\V-Ray\V-Ray for Rhinoceros 5\GrasshopperComponents\VRayForRhinoNETInterface.dll

The GrasshoppperComponents folder is not included in 6 and the dll was not included anywhere else. Thank you all for your help!

1 Like