-
Notifications
You must be signed in to change notification settings - Fork 335
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
90fcc28
commit 2ee0865
Showing
1 changed file
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
################################################################################ | ||
# SampleViewCaptureToFile.py | ||
# Copyright (c) 2018 Robert McNeel & Associates. | ||
# See License.md in the root of this repository for details. | ||
################################################################################ | ||
import System | ||
import Rhino | ||
import scriptcontext as sc | ||
|
||
# Demonstrates how to capture a view to a bitmap | ||
def SampleViewCaptureToFile(): | ||
view = sc.doc.Views.ActiveView; | ||
if view: | ||
view_capture = Rhino.Display.ViewCapture() | ||
view_capture.Width = view.ActiveViewport.Size.Width | ||
view_capture.Height = view.ActiveViewport.Size.Height | ||
view_capture.ScaleScreenItems = False | ||
view_capture.DrawAxes = False | ||
view_capture.DrawGrid = False | ||
view_capture.DrawGridAxes = False | ||
view_capture.TransparentBackground = False | ||
bitmap = view_capture.CaptureToBitmap(view) | ||
if bitmap: | ||
folder = System.Environment.SpecialFolder.Desktop | ||
path = System.Environment.GetFolderPath(folder) | ||
filename = System.IO.Path.Combine(path, "SampleViewCaptureToFile.png"); | ||
bitmap.Save(filename, System.Drawing.Imaging.ImageFormat.Png); | ||
|
||
# Check to see if this file is being executed as the "main" python | ||
# script instead of being used as a module by some other python script | ||
# This allows us to use the module which ever way we want. | ||
if __name__ == "__main__": | ||
SampleViewCaptureToFile() |