Jump to content

Save a View Transform (Persp) and Restore Back Later


gemini

Recommended Posts

I wrote a simple script which would toggle the actual persp camera with a camera in hip. So just to make it clear i have to save the persp camera translation ( here i save it to an other cam ) but when i would toggle back to persp view ( set the stored cam and i use useDefaultCamera ) it does not refresh the view to the new camera. It remain at the old camera settings. That's why i tried the updates.

Any Ideas ?

 

#run_after_save = 0
import toolutils
# Get the viewports from the sceneviewer
scene_viewer = toolutils.sceneViewer()
viewports = scene_viewer.viewports()
persp_viewport = viewports[-1]
look_trough_camera = persp_viewport.camera()

if look_trough_camera == None:
    persp_viewport.saveViewToCamera( hou.node('/obj/cam1'))
    persp_viewport.setCamera( hou.node('/obj/cam_XX'))
    print 1

else:
    persp_viewport.setCamera( hou.node('/obj/cam1'))
    persp_viewport.draw()
    hou.ui.triggerUpdate()
    persp_viewport.useDefaultCamera()
    
    print 2

    
    #hou.node('/obj/cam1').destroy()
    #import hdefereval
    #hdefereval.executeDeferred(hou.undos.performUndo)
    
 

Link to comment
Share on other sites

  • 2 months later...
  • 3 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...