Welcome to od|forum

Register now to gain access to all of our features. Once registered and logged in, you will be able to contribute to this site by submitting your own content or replying to existing content. You'll be able to customize your profile, receive reputation points as a reward for submitting content, while also communicating with other members via your own private inbox, plus much more! This message will be removed once you have signed in.

garf

Viewport Changed Python

Heya,

I've written a little python expression to scale geo dependent on through which camera is being viewed. It works but does not recognise when the viewport has changed - is there an event trigger I can use to get it to recognise this change?

 

import hou

desktop = hou.ui.curDesktop()
scene_viewer = desktop.paneTabOfType(hou.paneTabType.SceneViewer)
viewport = scene_viewer.curViewport()

camera = hou.GeometryViewport.camera(viewport)

if 'preview' in str(camera):
    return 0.01
    print 'preview cam'
else:
    return 1

Share this post


Link to post
Share on other sites

If you look at a recent post I made here, Alex Rusev gave me an excellent solution for getting an event trigger when a new node is selected. I strongly suspect you could use the same mechanism for finding out when the viewport changes. Essentially you just add a new eventLoopCallback() that compares the current viewport to a previously-stored viewport, and if they are different then do a thing (in my case, I needed to emit a Qt signal, in your case, scale geo). Not sure what your level of python is, but if you need help writing it I'll probably have some time to figure it out with you a little later today :)

Share this post


Link to post
Share on other sites

thanks - it's way overkill for what I need but it's good to know it's do-able

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now