Currently scratching my head over how to batch render using V-Ray from inside a plugin.
Using the following the renderer starts rendering fine.
Rhino.RhinoApp.RunScript("_-Render", true);
However, I’d like to take further action after the render is done, such as saving the render and loading a new file or turning off a layer and turning another on for the next render etc…
As long as all steps are scriptable, you can send more script commands.
The actions, like loading a new file and turning on/off layers are all scriptable.
To prevent getting a dialog box (“do you want to save changes?”) when you want to open a new file, you can first save the current document to a dummy file. After a document has been saved, you can open another document without any dialog.
Many commands have different behaviour when you run them in scripted mode (with a dash (-) in front of the command name). The Layer command is good example - use this to script layers on/off.
See below for a much better answer.
Ah, ok. Maybe (I don’t know and I haven’t tested) you can wait for the Idle event, prior to saving the file. So, hopefully what happens in the code below is that while rendering Rhino does not enter the Idle state and when the render is complete the Idle event is fired.
Enable Batch render in the VRay options, so your script does not get focus until the render has been finished. You can script these rhino commands, to start the render, save it and close the renderwindow:
_Render
_SaveRenderWindowAs
_CloseRenderWindow
After closing the render window, you can control layers etc. Apart from this, a few VRay options are accessable using either VRay plugin object or via the VRayForRhinoNETInterface. Here is a long thread to show how to use them via python, it sould work the same for a C# plugin.
Yes that’s exactly where I’m at, namely the Batch Render option in V-Ray.
@menno your code doesn’t work, I tried it simply to see if I can use it in different circumstances.
Edit:
@clement thanks for the link, that thread looks full of useful info for my current needs, I hope the updated V-Ray .Net lib works and has some goodies in there, going to check right now.
@netlander, just avoid using CancelRender() mentioned in that thread and do everything with the batchrender option enabled and it should all work. Good luck