Manipulating Rhino viewport via grasshopper

Hi Im trying to use the native grasshopper components to control the viewport. I want to use a target and camera location point to manipulate the perspective viewport… So far i’m stuck at the query viewports component.
Does anyone have some advice?


-F

@fredrik Have you found a solution?

I’m trying to set up a series of cameras with preset views of a model (SE, SW , NW & NE), before automatically generating screenshots for reports…

Are there any tutorials or guides out there?
thanks

@anders For my automated testing I also use a workflow where I modify the viewport and then take screenshots.

I used to do so by using Mod Viewport(human)
Along with View Capture (sasquatch).

Hereby an example attached
screenshot.gh (16.2 KB)

If you want to change viewports, you could use the rhino commands in a GhPython block. Or if you want to install yet another plug-in to help you do that you could opt for Flexibility as it has a ChangeViewport component.

Thank you @Martijn,
It works beautifully

Have you tried the native Grasshopper Rhino commands?…it seems like they should be able to something along the same lines, but I simply can’t find a way to make it work.

Hey @anders,

I have, I wrote my own custom plug-in for them which I unfortunately can’t share here. You could use the methods for Rhinoviewport:
https://developer.rhino3d.com/api/rhinocommon/rhino.display.rhinoviewport

Took me more or less 7 minutes to write you an example, from here you can take it further yourself I hope :wink:


Screenshot-2.gh (8.2 KB)

thank you again!

I was running on a lower knowledge level and just hoping to use the build in Rhino tools in Grasshopper…:wink:
image

I’ll absolutely use this as an opportunity to learn a little more about Rhino API scripting

@anders
Sure, no problem!

Perhaps to answer your question more properly in that case, I’m not aware of any native grasshopper function (in Rhino7) that can fulfill your request of adjusting the viewport & taking a screenshot.

Regarding learning the Rhino SDK, can recommend doing so. It really broadens your toolset and can help you improve your overall output.

Hej Anders -

You can use the Model View component to build a view, but you’ll then have to manually bake it to a named view. Currently, there aren’t any default components to automatically capture those to images.
-wim

I found my easiest path using two Human components… ‘Modify Viewport’ and ‘Save Viewport to File’. It works like a charm (both MAC and PC) so now I just have to find a way to automate the view changes and gab the screenshots (8 views/screenshots).