Enable Lock View to Camera in Python/Hscript

   1146   3   2
User Avatar
Member
155 posts
Joined: Sept. 2015
Offline
Is it not possible to enable the lock view to camera button via python/hscript?
User Avatar
Member
6 posts
Joined: Aug. 2015
Offline
experimenting w/python on this in Apprentice 16.5.634 (_old_ PC) and running into SAME issue(s)

https://www.sidefx.com/docs/houdini/hom/hou/GeometryViewport.html [www.sidefx.com]

… showed me several things which DO seem to work using the following syntax :

import hou, toolutils

myCam = hou.node('/obj/').createNode('cam', ‘myCam’)

hou.ui.paneTabOfType(hou.paneTabType.SceneViewer).curViewport().setCamera(myCam)

# hou.hscript('viewhome -s *.*.world.persp1')

hou.ui.paneTabOfType(hou.paneTabType.SceneViewer).curViewport().homeAll()

hou.ui.paneTabOfType(hou.paneTabType.SceneViewer).curViewport().saveViewToCamera(myCam)

# … HOWEVER, when I try something similar, I just get an Error on :

>>> hou.ui.paneTabOfType(hou.paneTabType.SceneViewer).curViewport().lockCameraToView()
Traceback (most recent call last):
File “<console>”, line 1, in <module>
AttributeError: ‘GeometryViewport’ object has no attribute ‘lockCameraToView’

# … and I have Not found any way to do this using hscript either. Anyone have advice on this?
User Avatar
Member
78 posts
Joined: Jan. 2016
Offline
Hi, I am not sure in which version the lockCameraToView() method has been implemented (probably 17.0 or later), but you need to add the argument, True or False into the lockCameraToView()

hou.ui.paneTabOfType(hou.paneTabType.SceneViewer).curViewport().lockCameraToView(True)
User Avatar
Member
6 posts
Joined: Aug. 2015
Offline
Yes, you are correct – lockCameraToView is Not there in 16.5

And I could have noticed that myself, had I bothered to look at the _internal_ hou.GeometryViewport HELP (instead of just online)

I will give it a try in 18 on my Son's (newly-built) PC when the opportunity presents itself

in the meantime I will probably try to make-do with “.saveViewToCamera(myCam)” (which IS there in 16.5), After user adjustments

(though I'm surprised there was never a way to do it using hscript)

Thank You for your patience and help on this!

-mike
  • Quick Links