Jump to content
mikelafave

Enable Lock View ( Viewport ) to Camera in Python/Hscript

Recommended Posts

https://www.sidefx.com/forum/topic/52186/     Oct. 19, 2017 4:14 P.M.     Is it not possible to enable the lock view to camera button via python/hscript?  

experimenting w/python on this in Apprentice 16.5.634 (_old_ PC) and running into issue(s)

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

... 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?

Share this post


Link to post
Share on other sites

Hi Michael,
you need to add the argument, True or False into the lockCameraToView()

hou.ui.paneTabOfType(hou.paneTabType.SceneViewer).curViewport().lockCameraToView(True)

 

Share this post


Link to post
Share on other sites

would that it were True

in Apprentice 16.5.634 , pasting that (and any other argument variation I can think of) into the Python Shell just gets me that same dead-end Error message :

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

>>> hou.ui.paneTabOfType(hou.paneTabType.SceneViewer).curViewport().isCameraLockedToView()
Traceback (most recent call last):
  File "<console>", line 1, in <module>
AttributeError: 'GeometryViewport' object has no attribute 'isCameraLockedToView'

? Q : Does this work for You now ... and, if it Does work for you, what version of Houdini does it now work in ?
 

Share this post


Link to post
Share on other sites

Hi,
I am using Houdini 18. I had this conversation with SideFX in April 2018. I don`t know, in which version the Lock method was implemented. But Houdini 16.5 was released earlier, November 2017. 

Sent: Wednesday, April 25, 2018 6:05 PM
Subject: Online Bug: python or hscript to toggle the lock [SESI #60637]
I've added you to an existing RFE requesting this functionality.
RFE #85473

 

You may try the following, in the Python Shell. The autocomplete will show you available methods in your version of Houdini, but lockCameraToView is probably not there:

image.png.7edb1632c0f8c95832b329b66f4dedbe.png 

 

Share this post


Link to post
Share on other sites

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, Jiri, for your patience and help on this!

-mike

  • Like 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×