mcjSelectTheseMats and mcjFlipMaterials


i wrote a script that selects the materials from a list

you'll have to modify the list "by hand" to make it work for your specific list of material names



use the Daz Studio scripting editor

or notepad and make sure to save the file in plain text format


it's programming code so you must use exactly the format used here

a list of material names enclosed in quotation marks, separated by comas

like

matNames = [ 
"SkinHead", 
"SkinScalp" 
];





var matNames = [

"SkinHead",

"SkinScalp"

];


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 D|S 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 D|S 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" );

}




the second script mcjFlipMaterials.dsa

inverts the current material selection

recently i went in Daz Studio 4.7’s dark-alley-menus and changed the way selection is done
because i was tired of having the root node selected each time i selected a bone ( for mcjAutoLimb work )
so maybe this is why i have to use the de-select/re-select trick to update the surfaces tap

warning—i think this script may not work in DS3, because many bone/shapes share the same materials 
so the same material may get toggled twice




var DSVersion = new Number( App.versionString );

var skel = Scene.getPrimarySelection();

//we'll detect users attempting to apply this script to the wrong figure


if( skel )

{

if( skel.inherits( "DzBone" ) )

{

skel = skel.getSkeleton();

}

var nodelist;

if( skel.inherits( "DzSkeleton" ) )

{

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 );

var sel = mat.isSelected();

mat.select( !sel );

}

}

//we want to de-select/re-select the root of the skeleton

//but we dont want to lose the surface materials selection

//so we will select one of its bones

var bones = skel.getAllBones();

var anybone = bones[0];

anybone.select( true );

skel.select( false );

skel.select( true );

}

else

{

MessageBox.information( "Please select a figure.", "Problem", "&OK;" );

}

}

else

{

MessageBox.information( "Please select a figure.", "Problem", "&OK;" );

}


ċ
mcjFlipMaterials.dsa
(2k)
mCasual Jacques,
Mar 8, 2015, 11:43 AM
ċ
mcjSelectTheseMats.dsa
(2k)
mCasual Jacques,
Feb 28, 2015, 2:53 PM
Comments