I am currently working on an asset browser and its corresponding export from Houdini.
Currently, I am at the point where I would like to create, export and render multiple views from the HIP.
I am running into issues with the frameSelected() function in the Geometry Viewport class.
A) This works:
- get the viewport
- frame selected
- save view to camera
Result: camera with framed geo
Python extract:
viewer = toolutils.sceneViewer() view = viewer.curViewport() cam = obj_level.createNode('cam', 'asset_cam') node.setSelected(True,True) view.frameSelected() view.saveViewToCamera(cam) view.setCamera(cam)
B) This does not work:
- create a camera
- set camera to viewport
- lock camera to viewport
- frame selected
Result: camera as it was initially created
Running the frameSelected function from the shell after my external script, it correctly frames the selection.
Python extract:
viewer = toolutils.sceneViewer() view = viewer.curViewport() cam_top = obj_level.createNode('cam', 'asset_cam_top') cam_top.parm('rx').set(-180) cam_top.parm('ry').set(-90) cam_top.parm('rz').set(90) view.setCamera(cam_top) view.lockCameraToView(1) node.setSelected(True,True) view.frameSelected()
C) This also does not work:
- create a camera
- set camera to viewport
- frame selected
- save view to camera
Result: camera with geometry that was framed inside the viewport before camera assignment
Python extract:
viewer = toolutils.sceneViewer() view = viewer.curViewport() cam_top = obj_level.createNode('cam', 'asset_cam_top') cam_top.parm('rx').set(-180) cam_top.parm('ry').set(-90) cam_top.parm('rz').set(90) view.setCamera(cam_top) node.setSelected(True,True) view.frameSelected() view.saveViewToCamera(cam_top)
I use the first scenario to send the current view or camera to render. But I would like to also send custom top and side view cameras. For this I would like to make the other scenario work (creating a cam with specific initial rotations and then framing the geo with it).
Does anyone have any idea why it does not frame the selection from the created camera's view?
What I tried additionally:
- I explicitly select the geo in my script after camera creation to make sure the selection is correct.
- After cam creation and setting the viewport to the cam, I make sure the viewport is correct by getting it again with toolutils.sceneViewer().curViewport() before trying to frame the selection.
What I will try next:
- Using the existing orthographic top and side views to frame and then save the view to a camera. This should theoretically work as it does work with the perspective view in the first scenario above.
If anyone encountered anything like this or has any ideas, please let me know! I greatly appreciate any hints and help
Big thanks and take care,
Dziga