Jump to content

Restore camera settings after a flipbook


Deivid3D

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:

Quote

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
camera.parm("vcomment").set(comment)
camera.parm("resx").set(1920)
camera.parm("resy").set(1080)
hou.GeometryViewport.setCamera(viewport, selected_cam)

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

flipbook_options.frameRange( (1001, 1050) )
flipbook_options.outputToMPlay(True)
#flipbook_options.cropOutMaskOverlay(False)
scene_viewer.flipbook(scene_viewer.curViewport(), flipbook_options)

#Recover Flipbook and camera settings
hou.GeometryViewportCamera.useDefaultCamera()
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.

Link to comment
Share on other sites

Hey,

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.

Link to comment
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
viewport.setDefaultCamera(prev_view)

 

  • Like 1
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...