Jump to content
Sign in to follow this  
Ryan

Resetting the Viewport

Recommended Posts

Posted (edited)

I wanted to share this script with you guys.

As we all know, viewport issues randomly occur at times. Geometry doesn't display properly, templated geo sticks to the view and doesn't go away, camera gets stuck in ortho mode, etc.

So a common fix for this is to just close the viewport and make a new one.

I have written a script you can add on your shelf for your convenience:

cur = hou.ui.paneTabOfType(hou.paneTabType.SceneViewer,0)
vp = cur.curViewport()
so = vp.settings().displaySet(hou.displaySetType.SceneObject)
fb = cur.flipbookSettings()
somode = so.shadedMode()

cam = hou.node("/obj").createNode("cam")
vp.saveViewToCamera(cam)
cam.parm("projection").set(0)

new = cur.pane().createTab(hou.paneTabType.SceneViewer)
nvp = new.curViewport()
ndm = nvp.settings().displaySet(hou.displaySetType.DisplayModel)
nso = nvp.settings().displaySet(hou.displaySetType.SceneObject)
nso.setShadedMode(somode)
nvp.setCamera(cam)
ndm.setLinkToDisplaySet(hou.displaySetType.SceneObject)
new.flipbookSettings().copy(fb)

cur.close()

cam.destroy()

This will also save your current camera position, shaded mode, and flipbook settings.

Enjoy!

Edited by Ryan
  • Like 2
  • Thanks 2

Share this post


Link to post
Share on other sites

Very useful and works really well! Thanks!

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
Sign in to follow this  

×