Disable Viewport Updating

I want to do heavy process, so viewport shouldn't be referesh/ updated, until the end.
any context or command to do this?

Comments

  • HowieFarkesHowieFarkes Posts: 607
    edited November 8

    I like to wrap this around any code that will potentially be slowed by the viewport being refreshed

     

    bool locked = dzApp->getInterface()->getViewportMgr()->isRedrawLocked();
    if ( !locked ) dzApp->getInterface()->getViewportMgr()->lockRedraws();
        
    // your code here
    
    
    dzApp->getInterface()->getViewportMgr()->unlockRedraws();
    dzApp->getInterface()->getViewportMgr()->repaintActive3DViewport();

     

    Post edited by HowieFarkes on
  • Richard HaseltineRichard Haseltine Posts: 100,888

    HowieFarkes said:

    I like to wrap this around any code that will potentially be slowed by the viewport being refreshed

     

    bool locked = dzApp->getInterface()->getViewportMgr()->isRedrawLocked();
    if ( !locked ) dzApp->getInterface()->getViewportMgr()->lockRedraws();
        
    // your code here
    
    
    dzApp->getInterface()->getViewportMgr()->unlockRedraws();
    dzApp->getInterface()->getViewportMgr()->repaintActive3DViewport();

    Thatv is SDK code, this is the scripting forum.

  • Richard HaseltineRichard Haseltine Posts: 100,888

    DS 4.22.1.88 (so present in the ciurrent General Release) added script features that should help:

    http://docs.daz3d.com/doku.php/public/software/dazstudio/4/change_log_4_23_0_1#4_22_1_88

  • HowieFarkes said:

    I like to wrap this around any code that will potentially be slowed by the viewport being refreshed

     

    bool locked = dzApp->getInterface()->getViewportMgr()->isRedrawLocked();
    if ( !locked ) dzApp->getInterface()->getViewportMgr()->lockRedraws();
        
    // your code here
    
    
    dzApp->getInterface()->getViewportMgr()->unlockRedraws();
    dzApp->getInterface()->getViewportMgr()->repaintActive3DViewport();

    this is great! thank you!
    script forum and sdk forum tied together,any code sdk code can be converted to the script code:
    App.getInterface().getViewportMgr().redrawsLocked(false)

  • Richard Haseltine said:

    DS 4.22.1.88 (so present in the ciurrent General Release) added script features that should help:

    http://docs.daz3d.com/doku.php/public/software/dazstudio/4/change_log_4_23_0_1#4_22_1_88

    what part might help?!

  • Richard HaseltineRichard Haseltine Posts: 100,888

    Not all SDK features work in Script and vice versa.

    In any event, in this case using the SDK calls is risky - if the script crashes out, or simply fails to complete the unlock step for some reason, then the Viewport can be left locked - the calls mentioned in the chnage log will unlock automatically when the script ends, so there is no risk of leaving the Viewport locked.

  • Richard HaseltineRichard Haseltine Posts: 100,888

    MehdiZangenehBar said:

    Richard Haseltine said:

    DS 4.22.1.88 (so present in the ciurrent General Release) added script features that should help:

    http://docs.daz3d.com/doku.php/public/software/dazstudio/4/change_log_4_23_0_1#4_22_1_88

    what part might help?!

    beginViewportRedrawLock() 

  • Aha, Thank You!
    so code should be

    beginViewportRedrawLock
    process...
    dropViewportRedrawLock

    what clearViewportRedrawLocks does?

  • I'm not sure, but it may be clearing all locks while the other two target only the active viewport.

  • OK, i just want to confirm that beginViewportRedrawLock does the job perfectly.
    I call clearViewportRedrawLocks at the end, until we found the official documentation.

  • Richard HaseltineRichard Haseltine Posts: 100,888
    edited November 10

    http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/object_index/global (I think this is brand new, I did look earlier - for what little that may have been worth)

    I think the idea is that you can stack mutliple locks during a script and they will not release until all are removed or the clear command is used to remove all of them at once - useful if you might soemtimes want the viewport to update, subject to coinditoons - but if you have just one lock at the beginning it doesn't matter whether you clear or drop (or indeed just exit the script, though that would be sloppy).

    Post edited by Richard Haseltine on
Sign In or Register to comment.