I am trying to set the camera to view through in the viewport in a LOP net from a python script, but having trouble navigating the python reference docs. My current code is this
but I get this error
TypeError: in method 'GeometryViewport_setCamera', argument 2 of type 'char const *'
Additional information:
Wrong number or type of arguments for overloaded function 'GeometryViewport_setCamer
a'.
Possible C/C++ prototypes are:
HOM_GeometryViewport::setCamera(HOM_ObjNode &)
HOM_GeometryViewport::setCamera(char const *)
I assume this because the camera node is of type hou.LopNode instead of a ObjNode. Any idea how I can change the viewport camera from python?
Have never tried but the last line look odd. I’m not at a machine. Maybe try something like: viewport.setCamera(”/obj/lopnet1/camera10”)
Now some time was given to test this, so here you go:
# code for setting a cameradefsetCamera(viewport='persp1',camera_path='/stage/camera1'):desktop=hou.ui.curDesktop()viewer=desktop.paneTabOfType(hou.paneTabType.SceneViewer)viewport=viewer.findViewport(viewport);viewport.setCamera(camera_path)# adjust the parms/argssetCamera(viewport='persp1',camera_path='/cameras/camera1')setCamera(viewport='persp1',camera_path='/cameras/camera2')