Script to set Glossy Roughness to Zero

Hi Guys, first time posting here ;-)

As per my thread title, I'm trying to code a script that will set the [material-> Glossy Roughness=ZERO] for all objects in my scene.

I'm completely new to DAZ API Scripting so, I'm completely lost, I've played with some free scripts available here, in specific with the mcjAllBlackExceptEmissive.dsa by mcasual.

But no joy so far, I dont think there is a functiom 'setGlossyColor' as it exists the 'setDiffuseColor' and like so 'SetGlossyRoughness' would be a bliss...

Like I said, I'm new to DAZ API Scripting but an expereinced Programer/Developer, but, also, I'm not trying to master the DAZ API, so I would not spend incontable number of hours to study/learn the DAZ API, and so to finish, A shortcut from any of you guys, would be very welcome.

Thanks all for reading,

M.

Comments

  • // DAZ Studio version 4.9.2.70 filetype DAZ Script// Remove all texture maps on "Glossy Roughness" and "Top Coat Roughness" in a DAZ scene.// By Esemwy, 2016.(function() {    var nNodes = Scene.getNumNodes();    for (var i = 0; i < nNodes; i++) {        var oNode = Scene.getNode(i);        // Do we have material nodes and objects present? If so then continue.        if (!oNode) continue;        var oObj = oNode.getObject();        if (!oObj) continue;        var oShape = oObj.getCurrentShape();        // Get the materials        var nMats = oShape.getNumMaterials();        for (var j = 0; j < nMats; j++) {            var oMat = oShape.getMaterial(j);            if (!oMat) continue;            // If the material has the property Glossy Roughness then clear it.            var oGR = oMat.findProperty("Glossy Roughness");            if (oGR && oGR.isMapped()) {                oGR.clearMap();                print ("%1/%2 %3 cleared".arg(oNode.name).arg(oMat.name).arg(oGR.name));            }            // If the material has the property Top Coat Roughness then clear it.            var oTCR = oMat.findProperty("Top Coat Roughness");            if (oTCR && oTCR.isMapped()) {                oTCR.clearMap();                print ("%1/%2 %3 cleared".arg(oNode.name).arg(oMat.name).arg(oTCR.name));            }        }    }})();

     

    The Mac users had a problem with these materials in 2016, and Esemwy wrote this to clear the maps. I assume it will still work.

  • // DAZ Studio version 4.9.2.70 filetype DAZ Script// Remove all texture maps on "Glossy Roughness" and "Top Coat Roughness" in a DAZ scene.// By Esemwy, 2016.// Modified on Sep/2021 by MBS// Sets "Glossy Roughness" value to 0 (ZERO)(function() {    var nNodes = Scene.getNumNodes();    for (var i = 0; i < nNodes; i++) {        var oNode = Scene.getNode(i);        // Do we have material nodes and objects present? If so then continue.        if (!oNode) continue;        var oObj = oNode.getObject();        if (!oObj) continue;        var oShape = oObj.getCurrentShape();        // Get the materials        var nMats = oShape.getNumMaterials();        for (var j = 0; j < nMats; j++) {            var oMat = oShape.getMaterial(j);            if (!oMat) continue;            // If the material has the property Glossy Roughness then clear it.            var oGR = oMat.findProperty("Glossy Roughness");           if (oGR && oGR.isMapped()) {                oGR.setValue(0);                print ("%1/%2 %3 Zeroed".arg(oNode.name).arg(oMat.name).arg(oGR.name));            }        }    }})();

    @https://www.daz3d.com/forums/profile/188120/Martirilla,

    Thanks so much!! The original script did not make any effect, it runs without any errors but no effect whatsoever, but I did modify (as above) and now it does exactly what I wanted!

    THANKS A MIL!!!

    MBS

     

  • Not sure if clearing the map is equivalent to setting to zero as OP requests, so this does both.

    dsa
    dsa
    Clear Glossy Roughess.dsa
    1K
  • Hi Ominiflux, thanks! But I got sorted out as my prev comment.

    I did not test your script, but seems to me that it will work as well.

     Thanks for thaking your time to reply.

    MBS.

     

    Omniflux said:

    Not sure if clearing the map is equivalent to setting to zero as OP requests, so this does both.

Sign In or Register to comment.