Phyton Issue with Adjusting Camera in Scene Viewer

   674   1   1
User Avatar
Member
2 posts
Joined: July 2016
Offline
Hello Houdini Community,

I'm currently facing an issue with adjusting the camera view in Houdini's Scene Viewer, and I'm hoping you can assist me with it.

My goal is to automatically adjust the view in the Scene Viewer to match the selected camera when I choose a camera from within a Subnet in a Solaris Stage using a Python script. I've tried various approaches so far, but without success.

Currently, I'm using the following script inside a action button but the plan is to use it later (when it is working) in the callscript section:

import hou

node = kwargs['node']
selected_camera_name = node.parm('variantname3').eval()
stage_path = '/obj/all'
camera_path = stage_path + '/' + selected_camera_name
camera_node = hou.node(camera_path)
desktop = hou.ui.curDesktop()
viewer = desktop.paneTabOfType(hou.paneTabType.SceneViewer)
viewport = viewer.curViewport()
viewport.setCamera(camera_node.path())

Although the script doesn't throw any errors, it is showing the right camera name in the Scene Viewer but doesn't change the view in the Scene Viewer according to the selected camera.

You can basiclic ignore the upper part of the script since this is working - the problem is somehow in the last 4 lines

desktop = hou.ui.curDesktop()
viewer = desktop.paneTabOfType(hou.paneTabType.SceneViewer)
viewport = viewer.curViewport()
viewport.setCamera(camera_node.path())

I guess that the viewport needs some update or transformation instruction but i could not find anything about it. I would greatly appreciate any hints or advice on how to resolve this issue. Are there specific functions or recommendations for automatically adjusting the camera view in the Scene Viewer?

Thank you in advance for your assistance.

Best regards
Edited by Robert Langnickel - Jan. 17, 2024 04:02:46
User Avatar
Member
2 posts
Joined: July 2016
Offline
Found the mistake: In LOPs, the camera path for 'setCamera' is meant to be a primitive path in the Solaris structure (eg: '/root/cameras') and not a path in the classical Houdini structure ('/obj/all').

Cheers Rob
  • Quick Links