[solved] VRay access in C# PlugIn

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

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

What would the equivalent be in C#?

A bit of background: 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.

you can do same thing, not in VS right now so something like

dynamic Vray;
Vray=Rhino.GetPluginObject(“V-Ray for Rhino”);

I’m pretty sure this will work, though you will have to know the methods explicitly. I thought Vray had a netinterface.dll it shipped with you could ref? Something like VrayNetInterface.dll or something. Probably in Vray folder somewhere, or maybe they discontinued it with latest version of Vray. I remember it being in Vray 2 folder.

For anyone in the future: I had to install V-Ray for Rhino 5 (previously had only 6) and it was in this directory:

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!

I have rhino 6 and new V ray. Is there any sample available for vray with rhino 6 in c#?

Hi everyone,

The VRayForRhinoNETInterface.dll is gone for good. It was just a wrapper around the COM API that VRayForRhino.rhp provids. Since all languages that Rhino understands know how to deal with COM APIs, the native approach can be used, and there is no need of a wrapper library.

You can check the V-Ray for Rhino API reference here:

And the same document can be found within the installation folder:

There are VisualBasic and IronPython code samples in both places. There is no C# samples, but it is rather straightforward - almost identical to the Python code.

Here is how to set the dmc noise threshold in C#:

dynamic vray = Rhino.RhinoApp.GetPlugInObject("V-Ray for Rhino");  
dynamic sis = vray.Scene.Plugin("/SettingsImageSampler");
sis.Param("type").Value = 1;
sis.Param("dmc_threshold").Value = 0.1;

If that seems too heavy there are shortcut method, that takes strings

dynamic vray = Rhino.RhinoApp.GetPlugInObject("V-Ray for Rhino");
dynamic scene = vray.Scene;
scene.SetSceneValue("/SettingsImageSampler", "type", "1");
scene.SetSceneValue("/SettingsImageSampler", "dmc_threshold", "0.1");

Plugin names and parameters can be found easily by just exporting a .vropt file from the Asset Editor and use if as a reference.
Otherwise you should look in V-Ray Plugin SDK for complete reference here: