Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Rendering and exporting proxy meshes, scenes, and animation can be done through Grasshopper's C# Script and/or GHPython Script components.  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.

...

Code Block
languagec#
VRayForGrasshopper.Scripting.VRayRenderer renderer = x as VRayForGrasshopper.Scripting.VRayRenderer; renderer.ExportScene(@"filePath\fileName.vrscene");

 

GhPython Script 


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_ToViewImage Added


Examples:

ToView - “Look through Camera“ in a specified View

Code Block
languagecpp
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

Code Block
languagecpp
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

Code Block
languagecpp
 (x as VRayForGrasshopper.Scripting.VRayCamera).ToActiveView();


FromActiveView - “Get Active Rhino Viewport”

Code Block
languagecpp
(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

Code Block
languagecpp
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

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


FromView - Sets the Grasshopper Camera in a specified View

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


ToActiveView - “Look through Camera“ in the Active View

Code Block
languagecpp
x.ActiveView()


FromActiveView - “Get Active Rhino Viewport”

Code Block
languagecpp
x.FromView()