How to set viewport type (top, bottom, etc) in Python

   1027   2   0
User Avatar
Member
438 posts
Joined: 8月 2019
Offline


How to switch the viewport type (top, bottom, etc) in Python?

Attachments:
Screenshot 2023-03-24 205240.png (39.7 KB)

User Avatar
Member
438 posts
Joined: 8月 2019
Offline
camera = viewport.defaultCamera()
camera.setRotation(
    hou.hmath.buildRotateZToAxis(
        hou.Vector3(0, -1, 0)
        ).extractRotationMatrix3()
)

It seems to work, but I'm not sure if modifying defaultCamera() is the recommended way to do it.
User Avatar
Member
4512 posts
Joined: 2月 2012
Online
You can do it like this:

desktop = hou.ui.curDesktop()
viewport = desktop.paneTabOfType(hou.paneTabType.SceneViewer)
if viewport.isCurrentTab():
    view = viewport.curViewport()
    view.changeType(hou.geometryViewportType.Perspective)
Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]

youtube.com/@pragmaticvfx | patreon.com/animatrix | animatrix2k7.gumroad.com
  • Quick Links