0

I have to run MEL script, but I am not sure. This is my code:

polyCube -w 2 -h 1 -d 2;
setAttr "pCube1.rotateY" 45;
setAttr "pCube1.translateY" 5;

I am trying to create a cube that high is 1, weight is 2 and d is 2 that will stay at y = 45. Am I wrong?

Any suggestions?

Naeem Ul Wahhab
  • 2,465
  • 4
  • 32
  • 59
Thien Tran
  • 11
  • 3

1 Answers1

0

Tried your code and it appears to work fine. What are you having trouble with?

A few notes: If you want to create multiple cubes with this, the name is going to change. To handle this, you can get the object name of the newly created poly cube. Another good practice is to wrap your code in curly braces { // my code } to avoid issues with variable scope.

{
    string $myCube[] = `polyCube -w 2 -h 1 -d 2`;
    setAttr ($myCube[0]+".rotateY") 45;
    setAttr ($myCube[0]+".translateY") 5;

    print($myCube); // outputs string array with object name and node name
}
Morten
  • 487
  • 2
  • 13