In general, homing resets the view direction to the default view, while framing keeps the current view direction and just moves the viewpoint.
Moves/tumbles the viewport to the default view.
Moves/tumbles the view to show all geometry/objects (including templated geometry). See also homeNonTemplated().
Moves/tumbles the view to show the selected geometry/objects.
Homes the viewport on the grid.
Moves/tumbles the view to show all non-templated geometry.
Moves/tumbles the viewport to show an arbitrary area in the scene.
Moves the view to show all geometry/objects. See also frameNonTemplates().
Moves the view to show an arbitrary area in the scene.
Moves the view to show the selected geometry/objects.
Frames the view on the grid.
Moves the view to show all non-templated geometry.
Viewpoint and cameras
Unlike some other 3D packages, in Houdini the view is not always linked to an actual Camera object. The may be "locked" to a camera (so changing the view tumbles/moves the camera), or it may be a "free" ("No camera") view not tied to a camera, or it may be temporarily looking through a camera (or light), but the view is not locked to the camera (so changing the view will not affect the camera). The user interface for these settings is the camera menu in the top right corner of each viewport, and the Lock Camera button on the view toolbar.
Most of the methods in this section are not affected by the difference. For example, if the view is "free", the defaultCamera() method will return an object that manipulates just the view, but if the view is locked to a camera, it will return an object that manipulates the linked camera.
You can tell if the view is currently looking through a camera/light if the result of camera() is not
None. This does not tell you whether the view is locked to the camera or not.
The following talks about the camera representing the "viewpoint" as a shorthand, however the viewport camera stores many settings besides the viewpoint position and direction, including pivot, aspect ratio, clipping planes, and so on.
Returns the transform from the modeling space to the space of the points in the geometry. When modeling at object level, this converts from the object space into the SOP’s space. When modeling at the SOP level, this is identity as the model space was the SOP space.
Equivalent to viewTransform, this is the transform matrix of the view. It converts from the camera’s space into the space that modeling is currently being done at.
Returns the transform from normalized device coordinates to the viewport camera’s space. This is often a projective transform, so if used the resulting points will have to be dehomogenized by dividing by w.
Returns the matrix converting from the viewport pixel coordinates to the normalized device coordinates. This is a two dimensional scale and translate, so the z and w components are identity.
Returns the matrix converting from the window pixel viewport coordinates to the viewport pixel coordinates. Window coordinates are present in hou.ViewerEvent and are unaware of quad-view viewports.
This is a two dimensional translate, so z and w components are identity.
Returns a hou.Vector3 representing the view pivot as a point in world space.
2-tuple of int
Returns the resolution of the viewport in pixels, as (width, height).
→ hou.ObjNode or
If the viewport is currently looking through a camera or light (not necessarily locked to it), this returns an object representing the camera/light’s node. Returns
None if the viewport is not looking through a camera/light.
Copies the viewpoint transform of the current view onto the transformation parameters of a camera or light node.
A hou.ObjNode object representing the node to save the view to.
Copies the viewport transform from the transformation parameters of a camera or light onto the current view. This is the same as choosing a camera/light from the Look through submenu in the viewport’s Camera menu.
A hou.ObjNode object representing the node to save the view from.
Returns an object representing the viewport’s viewpoint. The returned object is "live" in that changing its settings will immediately change the view
If a camera/ight is locked to the view, changing the settings of the
GeometryViewportCamera will change the camera/light node’s parameters as well.
Instead of a live object, you can get a "disconnected" version of the viewpoint using hou.GeometryViewportCamera.stash(). This is a useful way to remember a certain viewpoint in code for later. You can restore a "stashed" camera using setDefaultCamera().
# Remember the current view cam = viewport.defaultCamera() saved = cam.stash() # Change the view somehow # Restore the original view viewport.setDefaultCamera(saved)
Takes a hou.GeometryViewportCamera and copies its values into this viewport.
Set the current camera settings of the viewport to the settings stored in
cam_setting. If the viewport is looking through a camera and the view is not locked to the camera, it will be switched to "No camera". If the view is locked to the camera, the camera object will be updated instead.
Set the viewport camera to "No camera" and stop looking through a camera object (or light).
Query to see if the camera is locked to the view. This returns the state of the camera lock only; this can be enabled without viewing through a camera.
Set the viewport camera lock. When True, any changes to the view will affect the camera object being viewed though. When False, the camera will become disconnected from the viewport and revert to the default viewport camera when the user tumbles the view. It is possible to enable this without the viewport looking through a camera, though view changes will not affect any objects until the user sets the viewport to look through a camera or light.
Query if the viewport is currently displaying 2d geometry, often implying it is displaying UV information.
Query if the viewport is currently displaying 3d geometry. This is the case for perspective and ortho viewports.
Request that the viewport redraw. Multiple
draw() calls within the same script will be merged into a single call.
Query of the name of the viewport (
Set the name of the viewport. Setting the name does not affect its type, so naming a perspective view
front will be confusing. This is best used in conjunction with
Returns the hou.GeometryViewportSettings object for this viewport. By calling methods on that object, you can read/edit the viewport’s display options.
Returns the size of this viewport. The tuple elements are returned in viewport coordinates.
Xposition (lower left)
Yposition (lower left)
→ hou.geometryViewportType enum value
Query the viewport type (UV, 3D, top, left, etc).
Set the viewport type (hou.geometryViewportType). This method first attempts to restore a stashed view for the new viewport type, but failing that, will home the viewport.
Returns whether this viewport uses the construction plane when it is on.
Return the node draw at the specified pixel in the viewport, or
there is nothing there. The type of node returned depends on the level of
queryPrimAtPixel(node, x, y)
→ hou.Prim or
Return the primitive drawn at the specified pixel in the viewport, or
None if there is nothing there. The primitive returned will be a
subclass of hou.Prim.
The parameter node is used to restrict the query to geometry within a particular node. If node is None, then the query is unrestricted.
→ hou.Geometry or
Return the geometry currently being inspected in the viewport, or
when nothing is being inspected or when called outside of an inspect
→ hou.Prim or
Return the primitive currently being inspected in the viewport, or
when nothing is being inspected or when called outside of an inspect
script. The primitive returned will be a subclass of hou.Prim.
Convert world coordinates to viewport coordinates.
A hou.Vector3 containing a world space position.
Convert viewport coordinates to world coordinates. Returns a ray (direction vector and an origin point).
→ tuple of (int, int)
Convert from the Mouse CHOP’s X and Y screen values (which range from
1) to viewport coordinates, where
(0,0) is the bottom left corner of
Look up the world position and normal of geometry at viewport coordinates
(0,0) is the bottom left corner of the viewport. The returned tuple contains the position, normal, and a boolean flag that is
True if there is geometry at that screen position.
Register a Python callback to be called whenever a viewport event occurs. The event types are defined in hou.geometryViewportEvent.
Any callable Python object that expects keyworded arguments specific to an event type. This callback can be used for any geometry viewport event type.
Arguments for hou.geometryViewportEvent.CameraSwitched:
event_type: This viewport event.
desktop: The desktop object holding the scene viewer.
viewer: The scene viewer object holding the viewport.
viewport: The viewport object that triggered the event.
import hou def myViewportCB(**kwargs): event_type=kwargs['event_type'] desktop=kwargs['desktop'] viewer=kwargs['viewer'] viewport=kwargs['viewport'] print "\nmyViewportCB=",myViewportCB print "event type=",event_type print "desktop=",desktop print "viewer=",viewer print "viewport=",viewport cam = viewport.camera() print "camera=%s\n\n"%(cam.name()) curSceneViewer = [item for item in hou.ui.curDesktop().currentPaneTabs() if item.type() == hou.paneTabType.SceneViewer] curSceneViewer.curViewport().addEventCallback(myViewportCB)
Remove all Python callbacks that have been registered with hou.GeometryViewport.addEventCallback().
Remove a specific Python callback that have been registered with hou.GeometryViewport.addEventCallback().
Return a tuple of all the Python callbacks that have been registered with hou.GeometryViewport.addEventCallback().