Thursday, January 31, 2013

Using Variables with Maya Commands


import maya.cmds;
sphereNodes = maya.cmds.polySphere(); //create a sphere
sphereShape = sphereNodes[1]; //store the name of the polySphere node ("polySphere1") in another variable.

rad = maya.cmds.polySphere(
sphereShape, q=True, radius=True
); // use variable rad in conjunction with the polySphere command to query radius' value and store in rad
maya.cmds.polySphere(sphereShape, e=True, radius=rad*2); multiply the sphere's radius by 2

rad = maya.cmds.polySphere(
sphereShape, q=True, radius=True
); //reread the radius attribute from the sphere and store it in rad
maya.cmds.polyCube(
width=rad*2, height=rad*2, depth=rad*2
); //create a cube the same size as your sphere

RESULT: 


No comments:

Post a Comment