Below is an example demonstrating how you can collect information about the properties associated with a given material using the Property Group Tree.
// Define an anonymous function; // serves as our main loop, // limits the scope of variables (function(){ /*********************************************************************/ // Array<DzProperty> : A function for getting a list of the properties in a group function getGroupProperties( oGroup, bTraverse, bRecurse ) { // Declare an array to hold properties var aProperties = []; // If a group is not passed in if( !oGroup ){ // We are done, return an empty array return aProperties; } // Get the number of proeprties in the group var nProperties = oGroup.getNumProperties(); // Pre-size the properties array aProperties = new Array( nProperties ); // Iterate over the properties, setting each element in the array for( var i = 0; i < nProperties; i += 1 ){ // Assign the property to the position in the array aProperties[ i ] = oGroup.getProperty( i ); } // If we are recursing if( bRecurse ){ // Concatenate the properties array from child groups aProperties = aProperties.concat( getGroupProperties( oGroup.getFirstChild(), true, bRecurse ) ); } // If we are traversing if( bTraverse ){ // Concatenate the properties array from sibling groups aProperties = aProperties.concat( getGroupProperties( oGroup.getNextSibling(), bTraverse, bRecurse ) ); } // Return the array of properties return aProperties; }; /*********************************************************************/ // Array<DzProperty> : A function for getting the list properties for an element function getElementProperties( oElement, bTraverse, bRecurse ) { // Get the property group tree for the element var oPropertyGroupTree = oElement.getPropertyGroups(); // If the application version is 4.9.4.101 or newer and we want all properties if( App.version64 >= 0x0004000900040065 && bTraverse && bRecurse ){ // Return the properties for the element return oPropertyGroupTree.getAllProperties(); } // Get the first group in the tree var oPropertyGroup = oPropertyGroupTree.getFirstChild(); // Return the properties for the element return getGroupProperties( oPropertyGroup, bTraverse, bRecurse ); }; /*********************************************************************/ // DzProperty : A function for finding a property associated with an element function findElementProperty( oElement, sProperty, bUseLabel ) { // Whether or not to use optimizations; 4.7.1.44 or newer var bUseOptimization = (App.version64 >= 0x000400070001002c); // Declare a working variable var oProperty; // If the application version is 4.7.1.44 or newer and we are not using // the label to find, or the application version is 4.11.0.166 or newer if( (bUseOptimization && !bUseLabel) || App.version64 >= 0x0004000b000000a6 ){ // Get the property group tree for the element var oPropertyGroupTree = oElement.getPropertyGroups(); // If we are using the label if( bUseLabel ){ // Attempt to find the property oProperty = oPropertyGroupTree.findPropertyByLabel( sProperty ); // If we are not using the label } else { // Attempt to find the property oProperty = oPropertyGroupTree.findProperty( sProperty ); } // If we found a property if( oProperty ){ // We are done, return it return oProperty; } // Otherwise } else { // Get the properties of the element var aProperties = getElementProperties( oElement, true, true ); // Iterate over the properties for( var i = 0; i < aProperties.length; i += 1 ){ // Get the 'current' property oProperty = aProperties[i]; // If we are using the label if( bUseLabel ){ // If the label of the property is the one we are looking for if( oProperty.getLabel() == sProperty ){ // We are done, return it return oProperty; } // If we are not using the label } else { // If the name of the property is the one we are looking for if( oProperty.name == sProperty ){ // We are done, return it return oProperty; } } } } return null; }; /*********************************************************************/ // Array<DzProperty> : A function for getting the list properties for an element function getElementPropertiesInPath( oElement, sPath, bRecurse ) { // If the path is empty if( !sPath ){ // Return the properties for the element return getElementProperties( oElement, true, bRecurse ); } // Initialize var oGroup = oElement.getPropertyGroups(); var sName = ""; var nIdx = -1; var sSubPath = sPath; // While the remaining path is not empty while( oGroup && !sSubPath.isEmpty() ){ // Get the index of the first slash nIdx = sSubPath.indexOf( "/" ); // If a slash was not found if( nIdx < 0 ){ // The group name is the path sName = sSubPath; // Break the loop on the next evaluation sSubPath = ""; // If a slash was found } else { // The group name is before the slash sName = sSubPath.left( nIdx ); // Get the remaining path sSubPath = sSubPath.right( sSubPath.length - nIdx - 1 ); } // Get the sub group oGroup = oGroup ? oGroup.findChild( sName ) : null; } // Return the properties for the element return getGroupProperties( oGroup, false, bRecurse ); }; /*********************************************************************/ // void : A function for reporting information about a property function printPropertyInfo( oProperty ) { // Get the owner of the property var oOwner = oProperty.getOwner(); // Provide feedback print( String( "- %1 \"%2\" :: %3 (%4/%5) \"%6\"" ) .arg( oOwner.className() ) .arg( oOwner.name ) .arg( oProperty.className() ) .arg( oProperty.getPath() ) .arg( oProperty.name ) .arg( oProperty.getLabel() ) ); }; /*********************************************************************/ // DzNode : A function for getting the root of a node function getRootNode( oNode ) { // If a node is selected and it is a bone if( oNode && oNode.inherits( "DzBone" ) ){ // We want the skeleton return oNode.getSkeleton(); } // Return the original node return oNode; }; /*********************************************************************/ // Get the root of the primary selection var oNode = getRootNode( Scene.getPrimarySelection() ); // If nothing is selected if( !oNode ){ // We are done... return; } // Get the object for the node var oObject = oNode.getObject(); // If we do not have an object if( !oObject ){ // We are done.. return; } // Get the current shape for the object var oShape = oObject.getCurrentShape(); // If we do not have a shape if( !oShape ){ // We are done.. return; } // Get the selected materials var aMaterials = oShape.getAllSelectedMaterials(); // If we do not have any selected materials if( aMaterials.length < 1 ){ // Get all of the materials aMaterials = oShape.getAllMaterials(); } // Define what we are looking for var sPropertyName = "UV Set"; var sPropertyPath = "General"; // Initialize a list of properties var aProperties = []; // Declare working variables var oMaterial, oProvider, oProperty; var sMaterial; // Iterate over the materials for( var i = 0; i < aMaterials.length; i += 1 ){ // Get the 'current' material oMaterial = aMaterials[ i ]; // Get the name of the material sMaterial = oMaterial.name; // If the application version is 4.9.3.135 or newer if( App.version64 >= 0x0004000900030087 ){ // Find the simulation settings provider with the name of the material oProvider = oShape.findSimulationSettingsProvider( sMaterial ); // If the application version is older } else { // Simulation settings providers do not exist oProvider = undefined; } // If a property name is defined if( !sPropertyName.isEmpty() ){ // Find the property by name on the material oProperty = findElementProperty( oMaterial, sPropertyName, false ); // If the property is found if( oProperty ){ // Collect the property aProperties.push( oProperty ); // If the property is not found and we have a simulation settings provider } else if( oProvider ){ // Find the property by name on the provider oProperty = findElementProperty( oProvider, sPropertyName, false ); // If the property is found if( oProperty ){ // Collect the property aProperties.push( oProperty ); } } // If a property path is defined } else if( !sPropertyPath.isEmpty() ){ // Collect the properties at the specified path on the material aProperties = aProperties.concat( getElementPropertiesInPath( oMaterial, sPropertyPath, true ) ); // If we have a simulation settings provider if( oProvider ){ // Collect the properties at the specified path on the provider aProperties = aProperties.concat( getElementPropertiesInPath( oProvider, sPropertyPath, true ) ); } // If neither a property name nor a property path is defined } else { // Collect the properties on the material aProperties = aProperties.concat( getElementProperties( oMaterial, true, true ) ); // If we have a simulation settings provider if( oProvider ){ // Collect the properties on the provider aProperties = aProperties.concat( getElementProperties( oProvider, true, true ) ); } } } // Iterate over the collected properties for( var i = 0; i < aProperties.length; i += 1 ){ // Get the 'current' property oProperty = aProperties[ i ]; // Print information about the property printPropertyInfo( oProperty ); } // Finalize the function and invoke })();