Click or drag to resize

RhinoViewCaptureToBitmap Method (Boolean, Boolean, Boolean)

Captures the view contents to a bitmap allowing for visibility of grid and axes.

Namespace:  Rhino.Display
Assembly:  RhinoCommon (in RhinoCommon.dll)
Since: 5.0
Syntax
public Bitmap CaptureToBitmap(
	bool grid,
	bool worldAxes,
	bool cplaneAxes
)

Parameters

grid
Type: SystemBoolean
true if the construction plane grid should be visible.
worldAxes
Type: SystemBoolean
true if the world axis should be visible.
cplaneAxes
Type: SystemBoolean
true if the construction plane close the grid should be visible.

Return Value

Type: Bitmap
A new bitmap.
Examples
using System;
using System.Windows.Forms;
using Rhino;
using Rhino.Commands;

namespace examples_cs
{
  public class CaptureViewToBitmapCommand : Rhino.Commands.Command
  {
    public override string EnglishName
    {
      get { return "csCaptureViewToBitmap"; }
    }

    protected override Result RunCommand(RhinoDoc doc, RunMode mode)
    {
      var file_name = "";

      var bitmap = doc.Views.ActiveView.CaptureToBitmap(true, true, true);
      bitmap.MakeTransparent();

      // copy bitmap to clipboard
      Clipboard.SetImage(bitmap);

      // save bitmap to file
      var save_file_dialog = new Rhino.UI.SaveFileDialog
      {
        Filter = "*.bmp",
        InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)
      };
      if (save_file_dialog.ShowDialog() == DialogResult.OK)
      {
        file_name = save_file_dialog.FileName;
      }

      if (file_name != "")
        bitmap.Save(file_name);

      return Rhino.Commands.Result.Success;
    }
  }
}
Python
from scriptcontext import doc
from System.Windows.Forms import *
import Rhino.UI
from System import Environment

def RunCommand():
  file_name = "";

  bitmap = doc.Views.ActiveView.CaptureToBitmap(True, True, True)

  # copy bitmap to clipboard
  Clipboard.SetImage(bitmap)


  # save bitmap to file
  save_file_dialog = Rhino.UI.SaveFileDialog()
  save_file_dialog.Filter = "*.bmp"
  save_file_dialog.InitialDirectory = \
    Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)

  if save_file_dialog.ShowDialog() == DialogResult.OK:
    file_name = save_file_dialog.FileName

  if file_name != "":
    bitmap.Save(file_name)

  return Rhino.Commands.Result.Success

if __name__ == "__main__":
  RunCommand()
See Also