Jump to content

Restore camera settings after a flipbook

Recommended Posts

Hi everyone!


I'm starting to get into Python 2.7 for Houdini Indie (17.5) before jumping into Houdini 18 with Python 3, and I've been working in a flipbook tool until now everything is being okay but now I've found that I can't recover the camera settings/flipbook settings after generating the MPlay to maintain the user settings after applying the script. I've been trying to use the 'hou.GeometryViewportCamera.stash()'  to create a copy of the settings but I'm not sure how to use it and where should I recover these settings.

Also when I try to use it I get this error: 

'TypeError: unbound method setDefaultCamera() must be called with GeometryViewport instance as first argument (got nothing instead)'


I've created a simplified version of the script that I'll be attaching down below:


import hou

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

#Select Camera
cameras = hou.nodeType(hou.objNodeTypeCategory(),"cam").instances()
selected_cam = cameras[0].path()

#Set Camera comment parameter
comment = "Test Comment"

camera = hou.node(str(selected_cam))

#COPY THE CAMERA SETTINGS HERE<---------------------------------------
modify_cam = hou.GeometryViewport.setDefaultCamera()

#Modify some parameters
hou.GeometryViewport.setCamera(viewport, selected_cam)

#Jump to Flipbook
flipbook_options = scene_viewer.flipbookSettings().stash()

flipbook_options.frameRange( (1001, 1050) )
scene_viewer.flipbook(scene_viewer.curViewport(), flipbook_options)

#Recover Flipbook and camera settings
hou.GeometryViewport.setCamera(viewport, selected_cam)


If someone has any advice or idea of how would be the good approaching intro this, I'll bee really thankful.


Thanks in advance to everyone.

Share this post

Link to post
Share on other sites


Don't know if this is the most efficient method (someone please correct me if there is a better way) but maybe have a look at the hou.appendSessionModuleSource? (https://www.sidefx.com/docs/houdini/hom/hou/appendSessionModuleSource.html)

It's made to store variables in the HIP file itself. It's at least what I use when I need to store stuff like that. Essentially stores it as an environment variable that you can later call from anywhere in the HIP file with hou.session.variablename.

Share this post

Link to post
Share on other sites

useDefaultCamera and setCamera must be called on a GeometryViewport object. You have one in your script, 'viewport'. You can stash the default camera to a python object using:

prev_view = viewport.defaultCamera().stash()
// set your camera and flipbook


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