Welcome to the fun land of Mel

 

 

 

 

 

Rightyo, so if you have used maya for a while and want to learn some more about what this mel stuff is all about, it's time for a slight re-learn of Maya.

 

 

 

 

Example 1 : Querying Animation curves attached to a node

To query for an animated attribute, we need to get a list of all in-coming connections to the node and find out if they are animation curves.

 

 

			
			
			// this function takes the name of a node and prints 
			// the names of all animated attributes
			proc listAttachedAnimCurves(string $node) {
			
				// get the connections and connected nodes
				$src_a = `listConnections -s true -d false -c true $node`;
				$src_n = `listConnections -s true -d false $node`;
				
				print($node+"\n");

				for($i=0;$i<size($src_n);$i++) {
					$j = $i*2;

					// query the node type of the connected node
					$type = `nodeType $src_n[$i]`;
					
					// see if it's a 
					//   time to angular curve
					//   time to length curve  or a
					//   time to unitless curve
					if($type=="animCurveTA" || 
					   $type=="animCurveTL" ||
					   $type=="animCurveTU") {
					   print("\t"+$src_a[$j+1]+"\n");
					} 
				}
			}
	

 

 

Example 2 : Accessing Key Frames on a Curve

As previously mentioned, Maya's animation curves are based on hermite curves (see the devkit/animEngine example for a complete curve implimentation). Hermite curves are parametric curves which use tangents at their control points. Each control point will also contain an input and an output tangent. It is these tangents and points that are used to evaluate the curve.

 

 

			
			
			// this function takes the name of a node and prints 
			// the names of all animated attributes
			proc listAttachedAnimCurves(string $node) {
			
				// get the connections and connected nodes
				$src_a = `listConnections -s true -d false -c true $node`;
				$src_n = `listConnections -s true -d false $node`;
				
				print($node+"\n");

				for($i=0;$i<size($src_n);$i++) {
					$j = $i*2;

					// query the node type of the connected node
					$type = `nodeType $src_n[$i]`;
					
					// see if it's a 
					//   time to angular curve
					//   time to length curve  or a
					//   time to unitless curve
					if($type=="animCurveTA" || 
					   $type=="animCurveTL" ||
					   $type=="animCurveTU") {
					   print("\t"+$src_a[$j+1]+"\n");
					} 
				}
			}