Jump to content

Resetting the Viewport


Ryan

Recommended Posts

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
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...