Table of Contents

Rendering and exporting proxy meshes, scenes, and animation can be done through Grasshopper's C# Script and/or GHPython Script components.

The Camera component functions “Get Active Rhino Viewport” and “Look through Camera” can be done through the Script components.

Overview


Rendering and exporting proxy meshes and scenes (including animation) can be done through Grasshopper's C# Script and/or GHPython Script components. The methods are listed in the table below.


Require Render component as input:

public bool RenderAnimation();

Starts animation renderer.

public bool Render(bool sync = false); 


Starts renderer.

 true = function executed synchronously

 false = function executed asynchronously

public string ExportProxy(string filePath, bool animated = false);


Exports .vrmesh file (@" .vrmesh")

true = export as animated proxy

false = export as static proxy

public string ExportScene(string filePath, bool animated = false);


Exports .vrscene file (@" .vrscene")

true = export as animated proxy;

false = export as static proxy

public string ExportSequence(string filePath);Exports an animation sequence of V-Ray Scene (.vrscene) files (@" .vrscene")
public bool ExportCloud();Submits the current .vrscene file to Chaos Cloud.



Require Camera component as input.

public void ToView(Rhino.Display.RhinoViewport viewport, bool redraw = true);“Look through Camera“ in a specified View
true = redraw the view
public void FromView(Rhino.Display.RhinoViewport viewport, bool expireSolution = true);Sets the Grasshopper Camera in a specified View
true = solve the component after the parameters were set
public void ToActiveView(bool redraw = true);“Look through Camera“ in the Active View
true = redraw the view
public void FromActiveView(bool expireSolution = true);“Get Active Rhino Viewport”
true = solve the component after the parameters were set


C# Script 


Render Examples

1. Create a C# Script component and plug the renderer output in one of its inputs.

  


2. Add references to VRaySDK.Net.dll and VRayForGrasshopper.gha


3. In the code editor, cast the input variable to VRayForGrasshopper.Scripting.VRayRenderer.

VRayForGrasshopper.Scripting.VRayRenderer renderer = x as VRayForGrasshopper.Scripting.VRayRenderer; renderer.Render(false);
VRayForGrasshopper.Scripting.VRayRenderer renderer = x as VRayForGrasshopper.Scripting.VRayRenderer; renderer.ExportProxy(@"filePath\fileName.vrmesh");
VRayForGrasshopper.Scripting.VRayRenderer renderer = x as VRayForGrasshopper.Scripting.VRayRenderer; renderer.ExportScene(@"filePath\fileName.vrscene");


Camera Examples


Rhino 7

  1. Create a C# Script component and plug the Camera output in its x input.

  2. Right-click on the C# Script component > Manage Assemblies and add references to VRaySDK.Net.dll and VRayForGrasshopper.gha.

  3. In the code editor, import VRayForGrasshopper (“using VRayForGrasshopper;”) at the beginning of the document.

  4. In the code editor, cast the input variable to VRayForGrasshopper.Scripting.VRayCamera.

C_Sharp_Rhino7_ToView


Examples:

ToView - “Look through Camera“ in a specified View

Rhino.Display.RhinoView view = Rhino.RhinoDoc.ActiveDoc.Views.Find("Perspective", false);
    VRayForGrasshopper.Scripting.VRayCamera vcam = x as VRayForGrasshopper.Scripting.VRayCamera;
    if(vcam != null)
      vcam.ToView(view.ActiveViewport);


FromView - Sets the Grasshopper Camera in a specified View

Rhino.Display.RhinoView view = Rhino.RhinoDoc.ActiveDoc.Views.Find("Perspective", true);
VRayForGrasshopper.Scripting.VRayCamera vcam = x as VRayForGrasshopper.Scripting.VRayCamera;
if(vcam != null)
  vcam.FromView(view.ActiveViewport);


ToActiveView - “Look through Camera“ in the Active View

 (x as VRayForGrasshopper.Scripting.VRayCamera).ToActiveView();


FromActiveView - “Get Active Rhino Viewport”

(x as VRayForGrasshopper.Scripting.VRayCamera).FromActiveView();




Rhino8

  1. Create a C# Script component and plug the Camera output in its x input.

  2. In the code editor, import VRayForGrasshopper at the beginning of the document:
    // r "VRayForGrasshopper.gha"
    using VRayForGrasshopper;

  3. In the code editor, cast the input variable to VRayForGrasshopper.Scripting.VRayCamera.


Examples:


ToView - “Look through Camera“ in a specified View

Rhino.Display.RhinoView view = Rhino.RhinoDoc.ActiveDoc.Views.Find("Perspective", false);
if(x is VRayForGrasshopper.Scripting.VRayCamera vcam)
  vcam.ToView(view.ActiveViewport); 



GhPython Script 


Render Examples

1. Create a GhPython Script component and plug the renderer output in one of its inputs.


2. In the code editor, call any of the above methods on the input variable.

  


Camera Examples



1. Create a GhPython Script / Python 3 Script / IronPython 2 Script component and plug the Camera output in its x input.
2. In the Script editor, import Rhino and write the script


Examples:


ToView - “Look through Camera“ in a specified View

import Rhino
view = Rhino.RhinoDoc.ActiveDoc.Views.Find("Perspective", True);
x.ToView(view.ActiveViewport, True);


FromView - Sets the Grasshopper Camera in a specified View

import Rhino
view = Rhino.RhinoDoc.ActiveDoc.Views.Find("Perspective", True);
x.FromView(view.ActiveViewport, True);


ToActiveView - “Look through Camera“ in the Active View

x.ActiveView()


FromActiveView - “Get Active Rhino Viewport”

x.FromView()
Was this helpful?