Python Houdini

   5654   3   0
User Avatar
Member
71 posts
Joined: Feb. 2010
Offline
Hi all,
I have written a simple script to create a camera and look through the camera
but i have someproblem in setting the camera to look at the viewport

here is what i tried
hou.GeometryViewport.setCamera('cam1')

and below is the snapshot of the error im getting

please help me out. thank you

Attachments:
campythondoubt.jpg (53.6 KB)

User Avatar
Member
51 posts
Joined: Oct. 2006
Offline
You need an instance of GeometryViewport to call setCamera, it's not static. I think the full expression is something like this:
hou.ui.paneTabOfType(hou.paneTabType.SceneViewer).curViewport().setCamera(hou.node(“/obj/cam1”))

You can also execute hscript commands from Python:
hou.hscript(“viewcamera -c cam1 *.*.world.persp1”)
User Avatar
Member
71 posts
Joined: Feb. 2010
Offline
axebeak
You need an instance of GeometryViewport to call setCamera, it's not static. I think the full expression is something like this:
hou.ui.paneTabOfType(hou.paneTabType.SceneViewer).curViewport().setCamera(hou.node(“/obj/cam1”))

You can also execute hscript commands from Python:
hou.hscript(“viewcamera -c cam1 *.*.world.persp1”)

thank you very much.2nd one worked perfectly

but in my case.i creatd the camera through script and when the script is executed i want the camera to look through it rather than typing the script again.
is there any way for that?
User Avatar
Member
51 posts
Joined: Oct. 2006
Offline
Sure, just put one of those statements at the end of your script, something like:
myCam = hou.node(“/obj”).createNode(“cam”, “myCam”)
hou.hscript(“viewcamera -c ” + myCam.name() + “ *.*.world.persp1”)
  • Quick Links