Quantcast
Channel: Scripting - McNeel Forum
Viewing all articles
Browse latest Browse all 4125

Saving a specific area of the viewport as an image

$
0
0

Hi,

I’m looking for a way to save as a .jpg or .png file the elements that appear inside a specific area of the viewport and at a custom resolution . I was thinking about a Python script in Grasshopper that would take as inputs:

  • a closed polyline (area/contour of the canvas)
  • 2 ints (width and height in pixels)
  • 2 strings (path + file name)
  • a boolean (to trigger the saving of the image)

Is it feasible ?

Looking at the RhinoCommon API I found the following classes and functions that, I think, could be useful in this case but I can’t seem to figure out which one exactly is the most relevant and how to use it properly:

  • Rhino.Display.ViewCaptureSettings:

    • CropRectangle
    • DrawSelectedObjectsOnly
    • ViewArea
    • SetWindowRect
    • ViewAreaMapping
  • Rhino.Display.RhinoView:

    • Bounds
    • ClientRectangle
    • ScreenRectangle
    • Size

Could someone give me a hint on this ?

9 posts - 3 participants

Read full topic


Viewing all articles
Browse latest Browse all 4125