Hey folks,
I am currently trying to create a simple batch renamer. I basically have everything I need from some of the samples to go into my loop of iterating through each selected node, but I am not 100% sure how to access the material name so I can put this into a variable and then later write that back after I changed it with a simple string combine with my suffix variable. The string operation is no issue, that is simple, but reading out the correct data and then later writing it back, I really have no idea what I have to call.
This is my code snippet I have so far. I am on the right track as my little info output gives me correct number of materials and it is also doing it for each selected node, so in that regard all is good. I just dont know how to access the material name on that oMat, nor do I know how to write the data back afterwards. Please help me.
(function(){
var oNode;
var aNodes = Scene.getSelectedNodeList();
var nNodes = aNodes.length;
for( var i = 0; i < nNodes; i += 1 ){
oNode = aNodes[i];
var oObject = oNode.getObject();
if (! oObject) continue;
var nShapes = oObject.getNumShapes();
for (var j=0; j < nShapes; j++) {
var oShape = oObject.getShape(j);
var nMat = oShape.getNumMaterials();
for (var k=0; k < nMat; k++) {
var oMat = oShape.getMaterial(k);
// Info Output
print ( oMat, "num ", k);
}
}
}
})();