Grasshopper

algorithmic modeling for Rhino

My colleagues and I are working on some Python code which includes a heads up display containing information about the model.

We'd like for the HUD to only appear when the user is not moving the viewport around, or, in other words, when the current viewport camera is stationary for more than, say, a couple seconds.

Is there a way to listen for an event like a stationary camera?

Views: 833

Replies to This Discussion

doing such a thing requires - if I'm not mistaken - a bit of fancy footwork. There are events associated with camera motion - but in order to evaluate that a camera has NOT moved, you'll need to start a timer going in a background thread after every camera move that gets reset whenever the camera moves again - and once that timer hits a time threshold it triggers some delegate function.

Disclaimer: I know very little about event handling and even less about threading! so this could all be 100% wrong. 

Yes, it's possible. You could use the data dam and a camera component in order to do that; comparing the buffered data from the data dam with the current data would return false only when the camera is moving.

Here's a gif attached:

Attachments:

Although, upon rereading your question, it looks like you're doing it in python. You could activate the python component via the boolean returned, in that case.

I've attached a version using GHPython to get the camera location of the active viewport and a subsequent component which uses the sticky to store this vector and check the difference between the stored and the current vector. I think it should be possible to develop this logic within the same GHPython component. Hope that helps get the ball rolling :)

Attachments:

Just noticed that it only worked in perspective view. Added a tolerance input for checking if camera locations are the same. Attached..

Attachments:

Thank you Andrew, Dan, and Anders for your time! Very generous of you.

Will look into these suggestions this week.

B

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service