script for turning things on and off

davesolodavesolo Posts: 15
edited December 1969 in Daz Studio Discussion

how can i make a script to turn things on and off, like smoothing, point at, and shadows etc..

Comments

  • Richard HaseltineRichard Haseltine Posts: 102,252
    edited December 1969

    Here's an example of a script that turns smoothing off for all selected figures. Most of the other items would be properties of the figure, not its object, so you could skip that part of the code for those - just use figs[ n ].findProperty( name ); to get the control directly.

    // Get selected figures, declare other variables
    var figs = Scene.getSelectedSkeletonList();
    var nProps , nSmoothProps;
    var obj , smoothOnProp;
    var n , m , l;
    
    // Go through selected figures
    for ( var n = 0 ; n < figs.length ; n++ ) {
     // get the object, which is what owns the smoothing modifier
     obj = figs[ n ].getObject();
     if ( obj ) {
      // Since we have an object, get its modifiers and loop through them
      nProps = obj.getNumModifiers();
      for ( m = 0 ; m < nProps ; m++ ) {
       // If the modifier is a smoothing modifier
       if ( obj.getModifier( m ).inherits( "DzMeshSmoothModifier" ) ) {
        // get the on/off control, and if it's currently on turn it off
        smoothOnProp = obj.getModifier( m ).findPropertyByLabel( "Enable Smoothing" );
        if ( smoothOnProp ) {
         if ( smoothOnProp.getBoolValue() ) {
          // Turn smoothing off 
          smoothOnProp.setBoolValue( false );
         }
        }
       }
      }
     }
    }
  • JaderailJaderail Posts: 0
    edited December 1969

    Darn I love reading Richards codes. So smooth, so streamlined. Such good examples of coding...

Sign In or Register to comment.