/*
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 names (keys) to a native JScript array
var vbaAttribNames = new VBArray(oAttribs.Names);
var aAttribNames = vbaAttribNames.toArray();
// Print number of elements in this value map and then its values
Application.LogMessage("Found " + aAttribNames.length + " attribute(s) on " + oShaderDef.ProgID);
for (var i=0; i<aAttribNames.length; i++) {
var vKey = aAttribNames[i];
Application.LogMessage("Attribute["+i+"] has key,value: "+vKey+", "+oAttribs.Get(vKey));
}
// Expected output:
// INFO : Found 1 attribute(s) on mentalray.misss_physical_phen.1.0
// INFO : Attribute[0] has key,value: shaderlocation, 0
//
|