Traverse Surface Selection Sets?

Anybody know of a way to traverse surface selection sets or determine what sets a material is in?

I created an ugly way to do it with G3F, but I'd like something a bit more elegant.

var aTemplates = Array(    Array("Face", "Lips", "Ears", "EyeSocket"),    Array("Torso"),    Array("Toenails", "Legs"),    Array("Fingernails", "Arms"),    Array("Teeth", "Mouth"),    Array("Eyelashes"),    Array("Cornea", "Pupils", "Sclera", "Irises"),    Array("EyeMoisture"));function getTemplate(mat) {	var nTemplates = aTemplates.length;	for (var i = 0; i < nTemplates; i++) {		if ( aTemplates[i].indexOf(mat.name) >= 0 ) {			return "Template %1".arg(i+1);		}	}	return false;}//...

Thanks!

Comments

  • DAZ_cjonesDAZ_cjones Posts: 637
    edited January 2016

    The class you need is called: DzMaterialSelectionSet

    It is on DzShape. Neglecting error handling, here's a simple example that prints out their hierarchy.

    function printMaterialSelectionSetRecurse( oMaterialSelectionSet, sPrefix ){		var	sCurrentSelectoinSetPath = sPrefix + '/' + oMaterialSelectionSet.name;	print( "Selection Set Path: " + sCurrentSelectoinSetPath );	print( "Materials: " + oMaterialSelectionSet.getMaterialNames() );		for( var i = 0; i<oMaterialSelectionSet.getNumChildren(); ++i){		printMaterialSelectionSetRecurse( oMaterialSelectionSet.getChild(i), sCurrentSelectoinSetPath );	}}function printMaterialSelectionSet( oMaterialSelectionSetRoot ){	if( !oMaterialSelectionSetRoot ){		print("No selection sets");		return;	}			for( var i = 0; i<oMaterialSelectionSetRoot.getNumChildren(); ++i){		printMaterialSelectionSetRecurse( oMaterialSelectionSetRoot.getChild(i), "" );	}}printMaterialSelectionSet( Scene.getPrimarySelection().getObject().getCurrentShape().getMaterialSelectionSets() );

     

    Post edited by DAZ_cjones on
  • EsemwyEsemwy Posts: 578

    Exactly what I was after. Thanks so much!

Sign In or Register to comment.