Event for Viewport Change size / Position

Is there an appropriate event for me to hook into to track any time the viewport changes its position or size? I basically want to know where on screen a given viewport is at any time - even if the user moves the window, resizes the app or a viewport, etc.

Thoughts?

Which SDK are you using? RhinoCommon? C++? Scripting?

RhinoCommon. Sorry, should have specified!

I’ve checked the usual suspects RhinoView and RhinoViewport for relevant events, but they don’t seem to exist.
The only lead so far is the Handle property on the RhinoView class, you may be able to use some Windows native dll calls there, but that may be tricky…

Hi Andrew,

Any particular reason you need to know this?

– Dale

@dale I know it’s a bit of a hack - I’m rendering a WPF window (from inside a grasshopper plugin) and I’d like the ability to have that window follow the viewport location. I can get at the viewport’s size and position - but I don’t have a proper event to listen for to trigger changes to the window. Any thoughts? Better ways to approach the problem?

Rhino does not have an event that is triggered when a viewport has been resized.

If you had any C++ code, you could subclass the Rhino view - CRhinoView - and listen to WM_SIZE messages. But you cannot subclass in C#.

1 Like

I need this event because I have interactive drawings that I need to expire when the viewport size is changed, for example going from 4 views to 1. I can get around this by recalculating and comparing some cache, but this event would be convenient.

1 Like