// DAZ Studio version 3.1 and 4.x filetype DAZ Script // Select (highlight) just the following named surfaces on a named figure type, and apply a new shader preset to them // Derived from the script mcjSelectTheseMats by mcasual. Working in DAZ 4.12. // IMPORTANT Adjust as desired - i) the base figure name ii) material names to be targeted // and also the path to the shader to apply - C://your_folder/your_shader_preset.duf var figure = Scene.findNodeByLabel( "Genesis 2 Male" ); figure.select( true ); var matNames = [ "Ears", "Eyelashes", "Head", "Legs", "Face", "Feet", "Fingernails", "Forearms", "Gums", "Hands", "Head", "Hips", "InnerMouth", "Legs", "Lips", "Neck", "Nipples", "Nostrils", "Shoulders", "Teeth", "Toenails", "Tongue", "Torso" ]; var DSVersion = new Number( App.versionString ); var skel = Scene.getPrimarySelection(); //we'll detect users attempting to apply this script to the wrong figure var bFoundSomeMatches = false; if( skel ) { if( skel.inherits( "DzBone" ) ) { skel = skel.getSkeleton(); } if( skel.inherits( "DzSkeleton" ) ) { var nodelist; if( DSVersion >= 4.0 ) { //with version 4.0 and up, //the skeleton owns the DzObject //the DzObject owns the shape //the shape owns all the figure's materials nodelist = [skel]; } else { //with version 1, 2, 3 //each bone owns a DzObject //each DzObject owns a shape //each shape owns some or all the material figures nodelist = skel.getAllBones() } var nNodes = nodelist.length; for( var i = 0; i < nNodes; i++ ) { var obj = nodelist[i].getObject(); var shp = obj.getCurrentShape(); var nMats = shp.getNumMaterials(); for( var j = 0; j < nMats; j++ ) { var mat = shp.getMaterial( j ); if( matNames.find( mat.name ) >= 0 ) { bFoundSomeMatches = true; mat.select( true ); } } } if( !bFoundSomeMatches ) { MessageBox.information( "This script was designed\n" +" for adifferent figure than\n" +" the one you selected.", "Problem", "&OK" ); } } else { MessageBox.information( "Please select a figure.", "Problem", "&OK" ); } } else { MessageBox.information( "Please select a figure.", "Problem", "&OK" ); } // Path to shader to bulk load to the selected surfaces - slashes are forwards not backwards var sPathToFile = "C://your_folder/your_shader_preset.duf"; // Do the shader loading on selected surfaces App.getContentMgr().openFile( sPathToFile, true );