Use script to toggle Per Pixel Shading, Show Aspect Frame, and Show Thirds Guide?

argel1200argel1200 Posts: 759

Is it possible to write a script to toggle (or if necessary have separate "on" an 'off" scripts) the following?

Viewport(?) >> Show Aspect Frame
Viewport(?) >> Show Thirds Guide
Prefernces >> Interface >> Per Pixel Shading

I was looking at the example Action_Find_Classname scrip, but none of these appeare to be actions. So, I'm looking for some guidance on where to look in the scripting guides modify these settings. Mainly interested because I toggle them a lot. Especially Per Pixel Shading which needs to be toggled off to see textures on skydomes, the effects spheres in Render Sphere, etc. Thanks!

Comments

  • Richard HaseltineRichard Haseltine Posts: 100,842
    edited December 1969

    I'm not sure where, if at all, per-pixel shading is to be found but the other two are available as boolean properties of Dz3DViewport -

    aspectOn
    thirdsGuideOn

    So

    var VPMgr = MainWindow.getViewportMgr();
    if ( VPMgr ) {
     var VP = VPMgr.getActiveViewport();
     if ( VP ) {
      var TDVP = VP.get3DViewport();
      if ( TDVP ) {
       TDVP.thirdsGuideOn = true;
      }
     }
    }

    will get the viewport manager from the global MainWindow, the current viewport from the manager, and the current 3D viewport from the viewport and will then turn the thirds guide on.

  • argel1200argel1200 Posts: 759
    edited December 1969

    Thanks Richard!! For anyone curious, here are two scripts that toggle each, respectively.

    Thirds:

    var  VPMgr                         =  MainWindow.getViewportMgr();
    if ( VPMgr ) {  var VP             = VPMgr.getActiveViewport();
    if ( VP    ) {  var TDVP           = VP.get3DViewport();
    if ( TDVP  ) {  TDVP.thirdsGuideOn = ! TDVP.thirdsGuideOn; }}}

    Aspect:

    var  VPMgr                    =  MainWindow.getViewportMgr();
    if ( VPMgr ) {  var VP        = VPMgr.getActiveViewport();
    if ( VP    ) {  var TDVP      = VP.get3DViewport();
    if ( TDVP  ) {  TDVP.aspectOn = ! TDVP.aspectOn; }}}
  • argel1200argel1200 Posts: 759
    edited December 1969

    More improvements. Now the script that toggles the thirds guide also turns the aspect frame on and the aspect frame script turns the thirds guide off if the aspect frame is toggled off. For anyone reading this a few years from now, these work with DAZ Studio 4.7.0.12.

    Thirds Guide:

    // Toggles the Thirds guide and turns the aspect frame on if the thirds guide is toggled on. 
    // Uncomment the 'TDVP.aspectOn=false' if you want to toggle the thirds guide and the aspect frame.
    var  VPMgr =  MainWindow.getViewportMgr();
    if ( VPMgr ) {  
     var VP = VPMgr.getActiveViewport();
     if ( VP ) {  
      var TDVP      = VP.get3DViewport();
      if ( TDVP ) { 
       if( TDVP.thirdsGuideOn ){ TDVP.thirdsGuideOn = false; /* TDVP.aspectOn      = false; */ }
       else                    { TDVP.aspectOn      = true;  TDVP.thirdsGuideOn = true;  }
       }
      }
     }

    Aspect Frame:

    // DAZ Studio version 4.7.0.12 filetype DAZ Script
    //Toggles the Aspect Frame and turns the thirds guide off if the aspect frame is toggled off
    var  VPMgr =  MainWindow.getViewportMgr();
    if ( VPMgr ) { 
     var VP = VPMgr.getActiveViewport();
     if ( VP ) {  
      var TDVP = VP.get3DViewport();
      if ( TDVP ) { 
       if( TDVP.aspectOn ) { TDVP.thirdsGuideOn = false; TDVP.aspectOn = false } 
       else                { TDVP.aspectOn      = true;                        }
       }
      }
     } 
    
  • barbultbarbult Posts: 24,243
    edited December 1969

    Thanks for sharing your scripts.

  • argel1200 said:

    For anyone reading this a few years from now, these work with DAZ Studio 4.7.0.12.

    And for anyone reading this past 2021, they still work in Daz 4.15.0.2.

    Thank you very much!  I use the thirds guide quite a bit and was frustrated trying to find a way to keybind it.

  • jhoffmann said:

    argel1200 said:

    For anyone reading this a few years from now, these work with DAZ Studio 4.7.0.12.

    And for anyone reading this past 2021, they still work in Daz 4.15.0.2.

    Thank you very much!  I use the thirds guide quite a bit and was frustrated trying to find a way to keybind it.

    Glad you find them useful! I can't imagine going back to not having them!!

Sign In or Register to comment.