/*
This example demonstrates how to access and work with the list of attributes
(stored in a ValueMap object) in JScript. When using JScript, you have to
be careful to convert the safearrays returned by the Names and Values properties
to JScript native arrays before you can work with them.
*/
NewScene("", false);
// Get the first ShaderDef in the system
var oShaderDef = Application.ShaderDefinitions(0);
// Get its attributes
var oAttribs = oShaderDef.Attributes;
// Convert the list of values to a native JScript array
var vbaAttribValues = new VBArray(oAttribs.Values);
var aAttribValues = vbaAttribValues.toArray();
// Print number of elements in this value map and then the list of values
Application.LogMessage("Found " + aAttribValues.length + " attribute(s) on " + oShaderDef.ProgID);
for (var i=0; i<aAttribValues.length; i++) {
var vVal = aAttribValues[i];
Application.LogMessage("Attribute["+i+"] has value: "+vVal);
}
// Expected output:
// INFO : Found 1 attribute(s) on mentalray.misss_physical_phen.1.0
// INFO : Attribute[0] has value: 0
//
|