Export As: [ PDF | ODT ]

Node Property Presentations

Summary

Below is an example demonstrating how you can use a property's presentation to provide a visual indication of information about the property.

API Areas of Interest

Example

Click the name of the example below to save it as a file.

Node_Property_Presentations.dsa
/*********************************************************************/
// Array<DzProperty> :
function getGroupProperties( oGroup, bTraverse, bRecurse )
{
	// Declare an array to hold properties
	var aProperties = [];
 
	// If a group isn't passed in
	if( !oGroup ){
		// We're done, return an empty array
		return aProperties;
	// If a group is passed in
	} else {
		// 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 ){
			aProperties[ i ] = oGroup.getProperty( i );
		}
 
		// If we are recursing
		if( bRecurse ){
			// Concatenate the properties array from child groups
			aProperties = aProperties.concat( getGroupProperties( oGroup.getFirstChild(), bTraverse, 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> :
function getNodeProperties( oNode, bTraverse, bRecurse )
{
	// Get the property group tree for the node
	var oPropertyGroupTree = oNode.getPropertyGroups();
	// Get the first group in the tree
	var oPropertyGroup = oPropertyGroupTree.getFirstChild();
	// Get the properties for the node
	return getGroupProperties( oPropertyGroup, bTraverse, bRecurse );
}
 
/*********************************************************************/
// Get the primary selection
var oNode = Scene.getPrimarySelection();
// If something is selected
if( oNode ){
	// Get the properties available to the user by way of the selected node
	var aProperties = getNodeProperties( oNode, true, true );
	// Declare variables we'll be using as we iterate
	var oProperty, oOwner, oPresentation;
	// Iterate over all properties
	for( var i = 0; i < aProperties.length; i += 1 ){
		// Get the "current" property
		oProperty = aProperties[ i ];
		// Get the owner of the property
		oOwner = oProperty.getOwner();
 
		// Get the property's presentation
		oPresentation = oProperty.getPresentation();
		// If the property doesn't have a presentation, skip it
		if( !oPresentation ){
			continue;
		}
 
		// If the property is on the node itself 
		if( oOwner.inherits( "DzNode" ) ){
			oPresentation.colorA = new Color( 41, 41, 0 );
		// If the property is on a morph 
		} else if( oOwner.inherits( "DzMorph" ) ){
			oPresentation.colorA = new Color( 0, 41, 0 );
		// If the property is on another element 
		} else {
			oPresentation.colorA = new Color( 0, 41, 41 );
		}
 
		// If the name of the owner of the property begins with CTRL 
		if( oOwner.name.startsWith("CTRL") ){
			oPresentation.colorB = new Color( 141, 141, 0 );
		// If the name of the owner of the property begins with FBM
		} else if( oOwner.name.startsWith("FBM") ){
			oPresentation.colorB = new Color( 0, 141, 0 );
		// Everything else
		} else {
			oPresentation.colorB = new Color( 0, 141, 141 );
		}
	}
}