Mel Script - getAttr and setAttr

 

 

 

Within maya all data is stored as seperate nodes. ie, you may have a material node, a mesh node and a transform node. Those node in turn all contain attributes, which we really need to be able to query and alter. For a complete list of all node types and the attributes they contain, take a look at the DG node reference in the Developers section of the Maya help.

 

 

 

 

Example

This example simply creates a polygon cube and then changes the attributes contained on the poly cube node.

 

 

		
		{		
			// create a poly cube
			polyCube;
			
			// set the subdivisions on the polyCreator node
			setAttr "polyCube1.subdivisionsWidth" 10;
			setAttr "polyCube1.subdivisionsHeight" 10;
			setAttr "polyCube1.subdivisionsDepth" 10;
			
			// set the subdivisions on the polyCreator node
			print( `getAttr "polyCube1.subdivisionsWidth"` + " "+
			       `getAttr "polyCube1.subdivisionsHeight"` + " "+
			       `getAttr "polyCube1.subdivisionsDepth"` + "\n");
		}