V ray and rhino 6 c# example

I need V ray and rhino 6 c# example

To do… what?

To export scene from vray into file folder in rhino 6.0 via script c#.
The old method- is not working for me
RhinoApp.RunScript("_-visSetExportVRScene " + customFilelocation, false);

Hi Amitloh
what you’re basically doing is to run a command called visSetExportVRScene.

All vis- commands were renamed to vray- commands back in 3.60 (around 2 years ago).
Furthermore the new command is refactored a bit and its name was changed again to vrayExportVRScene

All this information is available in the Rhino’s plugin options dialog:
image

To Run the command transparently using a C# script you call:

RhinoApp.RunScript("-vrayExportVRScene " + customFilelocation, false);

Thank you! My example some how not exporting whatever I do. Do you have sample c# code that works and exports any scene to file folder? I am able to export to png using
Rhino.RhinoApp.RunScript(@"_-ViewCaptureToFile D:\viewCaptureDemo.png _Enter", true);
but not scene

change the echo argument to true, and check what is written out on the command line, then debug your code

Ok I will check that. Thanks! I am able to export scene manually so that works but not via c# code.

I have echo on. Where do I see the error. I am debugging via visual studio. I get nice picture as png but scene says false in return, In png command it returns true and I get nice png.

I am also getting vray.DoNotRenderFinalImage is not found error, when I comment it code runs but without scene
same issue for vray.SetGIOn

all of the properties you quoted are obsolete and long gone.
None of them will work. Only the official API here:
https://docs.chaosgroup.com/display/VNFR/V-Ray+Script+Access

The command error will be written out on the command line, as every other command error.

ok thanks you. I do not see any method to export a scene…
Option Explicit

Dim vray, scene
Set vray = Rhino.GetPlugInObject("V-Ray for Rhino")
Set scene = vray.Scene
I can see scene object when I debug but how do I export? and like vs methods is there any way when I put vray. I get all methods?

there is no export method on the scene object. There is the “vrayExportVRScene” command for that.

ok right and thats the thing thats not working for me. Scratching my head…
Rhino.RhinoApp.RunScript(@"_-ViewCaptureToFile D:\viewCaptureDemo.png _Enter", true);
this works

what is written out on the Rhino’s command line ?
I don’t have a .net plugin setup, so I’m using Grasshopper to run the code
and it works for me.

If it works manually but not work from your plugin code, you might be hitting some vrayExportVRScene limitations.
It requires V-Ray to be current renderer, and the renderer should not be rendering at the time of the export. It also requires valid license and successful Rhino model processing (quite obvious)

You may also try to invoke the _Render command. It shares 90% of the code with vrayExportVRScene, only that it does not start rendering, but writes out a file

It requires V-Ray to be current renderer, and the renderer should not be rendering at the time of the export. It also requires valid license - I have valid trial and manual export is working. Does it need purchased license?

adv, trial, edu, nfr, beta, every license will work

Thanks man! will again try tomorrow morning, not sure why its not working.

vrayExportVRScene I tried but without any working sample or help its just impossible to crack this. There are syn-taxes saying Enter worked for exporting png and that works but last 4 do not.
Rhino.RhinoApp.RunScript(@"
-ViewCaptureToFile D:\viewCaptureDemo.png Enter", true);
RhinoApp.RunScript(@"
-vrayExportVRScene " + vrsFile+ " Enter", true);
RhinoApp.RunScript(@"
-vrayExportVRScene D:\test.vrscene Enter", true);
RhinoApp.RunScript(@"
-vrayExportVRScene D:\test.vrscene", true);
RhinoApp.RunScript(@"_-vrayExportVRScene D:\test.vrscene _Enter", true);

My scene is not in rendering mode and I am able to export manually.

I set up a .NET plugin from the Rhino templates, and writing exactly 2 lines of code to make it work without any problem.

protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
    return RhinoApp.RunScript("_-vrayExportVRScene D:\\test.vrscene _Enter", true) ? Result.Success : Result.Failure;
}

Make sure you put the ScriptRunner attribute on your command, as explained in this article:

Without that attribute you will be only able to run built-in Rhino commands (although that shouldn’t be allowed as well)

Thank you!!!