hou.GeometryViewport

   4104   2   1
User Avatar
Member
18 posts
Joined: Sept. 2013
Offline
I want to use python to center the current viewport. I've tracked it down to

hou.GeometryViewport().homeAll()
Traceback (most recent call last):
File “<console>”, line 1, in <module>
File “CPROGRA~1/SIDEEF~1/HOUDIN~1.470/houdini/python2.7libs\hou.py”, line 39628, in __init__
def __init__(self): raise AttributeError, “No constructor defined”
AttributeError: No constructor defined

but that doesn't work. I'm not sure what the proper syntax is.

I've also tried:
import toolutils
viewer = toolutils.sceneViewer()
hou.GeometryViewport(viewer).homeAll()
Traceback (most recent call last):
File “<console>”, line 1, in <module>
TypeError: __init__() takes exactly 1 argument (2 given)


Thanks in advance.

/R
lights, camera, … life …
User Avatar
Staff
4565 posts
Joined: July 2005
Offline

import toolutils
viewer = toolutils.sceneViewer()
viewer.viewports().homeAll()


The “viewer” will be a Scene Viewer pane (if one is open). But the scene viewer pane has four viewports (even if you are not in quad view, the four viewports are always there). In my case, my perspective viewport was the third one in the list returned by “viewer.viewports()”. You will probably want some logic in there to choose which viewport to home (or you could loop through and home all of them).

Hope that helps,
Mark
User Avatar
Member
18 posts
Joined: Sept. 2013
Offline
ok, looping through works fine.

Tanks!
lights, camera, … life …
  • Quick Links