Jump to content

Viewport Changed Python


garf

Recommended Posts

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

Link to comment
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 :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...