Enable Lock View to Camera in Python/Hscript
3395 3 2-
- Brian Walters
- Member
- 155 posts
- Joined: Sept. 2015
- Offline
-
- lafave
- Member
- 8 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?
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?
-
- ikoon
- Member
- 214 posts
- Joined: Jan. 2016
- Offline
-
- lafave
- Member
- 8 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
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