I wanted to make my own version of VRay animation from grasshopper, but there are some closed doors for me.
I have something like this:
Private Sub RunScript(ByVal Run As Boolean, ByVal Folder As String, ByVal W As Integer, ByVal H As Integer, ByRef A As Object)
Dim Vid As guid = rhino.PlugIns.RenderPlugIn.IdFromName("V-Ray for Rhino")
Dim VRay = rhino.RhinoApp.GetPlugInObject(Vid)
' VRay.SetAdaptiveDMCMinMaxSubdivs(10, 20)
' VRay.SetAdaptiveSubdivisionNormals(1, 0.0)
'Load and apply vismat.
For i As int32 = 0 To vismat.count - 1
Dim idxof1 As Integer = vismat(i).LastIndexOf("\")
Dim idxof2 As Integer = vismat(i).LastIndexOf(".")
Dim namematerial As String = vismat(i).substring(idxof1 + 1, idxof2 - idxof1 - 1)
'Dim find As int32 = rhino.DocObjects.Tables.MaterialTable.Find(namematerial, True)
' print(find) 'This return -1
If find <> -1 then
Rhino.RhinoApp.RunScript("_-visLoadVismat " & vismat(i), True)
' rhino.RhinoApp.RunScript("_-visApplymaterial", True)
If Run Then
' Rhino.RhinoApp.RunScript("_-SaveRenderWindowAs " & vbLf & """" + Folder + """" & vbLf, False) iter += 1
So when I run the script, new materials (duplicate) appear. How do I avoid that? there is away to check if there is already a material with that name?
How render is executed from Vray. (…)?
How the materials are loaded and applied?
Dim materials As String() = Nothing
Now works. But please @matt_newberg would be so kind as to tell me what are the functions to render, save image, load material, apply materials… ?? I would avoid using rhinoapp.runscript ()
Could you tell me if there is also a function that determines if the render is complete or is in process?
Of course, I will post the script here and Gh forum when I finish it.
The code is C++, but you should be able to get the idea.
LoadVisopt, LoadVismat, LoadDirectoryOfVismats should all be in the RhinoScript interface you are currently uses.
Running visApplyMaterials should work fine run script. You would be amazed what you can do with running scripts. There is another solution which I will get to later on.
Ok, we currently do not have a RhinoScript function that does this, but we have had a C export that will give you the status of the renderer. In order to access this you can add a reference to the he attached wrapper DLL and call VRayInterface.HasRenderFinished() VRayForRhinoNETInterface.zip (11.1 KB) You can also call the same methods by manually pInvoking the needed functions with the code in the attached grasshopper file tryGHVRAYanimation_hasRender.gh (9.6 KB)
In both methods (DLL or code) I have also attached the methods for applying materials.
Edited: Documentation about these methods can be found in the file:
Wow, I did not expect so much contribution! Thank you so much, I have a lot to learn here
But it’s bittersweet, because I’ve closed this project. The result is more superficial, but it works. Thanks anyway, sure for someone else will be very useful.
@matt_newberg, LoadVismat works pretty well for loading materials and applying them using a combination of scriptcontext.doc.Materials and rhinoscriptsyntax. The problem with LoadVismat in a script is the need for feeding a file path which gets tricky when working between multiple computers.
So I am wondering if there is a way to circumvent LoadVismat for adding a material to the material table?