Can anyone help please? I'm trying to write a simple MEL script that will ask the user for a number, then create that number of polycubes. I can manage to do that and I've got validation so that the user can only input a number between 4 - 32.
However, when it comes to creating the cubes is where I am having difficulty in getting my head around the logic.
What I want to do is start with a specified polygon size (2.5,1,5) then have each successive polygon scale up in one dimension. In addition to that I want to displace the cubes progressively so that in the end I have what looks like a staricase of cubes.
But... what happens is that although the right number of cubes is created, only one of them is moved to the position I want (so far I haven't tried the scaling). I suspect I need to create a new variable to do it, but I am stumped as to how.
Any help will be very gratefully received
Thanks
Rosanne
This is my code so far
global int $No_of_Cubes;
global proc makeCube(int $No_of_Cubes) {
//Sets the $count variable as an integer
global int $No_of_Cubes;
int $count;
for ($count = 0; $count < $No_of_Cubes; $count ++)
polyCube -w 2.50 -h 1 -d 5 ;
move -y .5;
//Trying to create shader - doesn't work
//createAndAssignShader lambert "";
//connectAttr -f lambert2.outColor lambert2SG.surfaceShader;
//sets -e -forceElement lambert2SG;
//displace cubes
move ($count * .5) ($count *.25) 0;
}
//global proc buttonAction(){
//else makeCube($No_of_Cubes);
//buttonAction();
//}
global proc makeCubeUI(){
global int $No_of_Cubes;
string $getNoCubes = `promptDialog -title "Mystery!"
-message "Please enter a number between 4 and 32"
-b "Click to see what happens next"`;
string $getCubeString = `promptDialog -q`;
int $No_of_Cubes = $getCubeString;
//validates $No_of_Cubes is > 4 or >32
//if yes, error message and reset
// int $No_of_Cubes;
global int $No_of_Cubes;
if (($No_of_Cubes <4)||($No_of_Cubes >32)){
confirmDialog -t "Oops!"
-m "Number must be between 4 - 32"
-button "ok";
makeCubeUI();
}
makeCube($No_of_Cubes);
}
makeCubeUI();
Hi
It looks like you were quite close. Your problem was that you didn't put braces (the curly ones {}) after your for loop and so it was only looping over the first command (the polyCube command in this case). So to fix it I just added the braces. Your makeCube function now looks like this:
global proc makeCube(int $No_of_Cubes) {
//Sets the $count variable as an integer
global int $No_of_Cubes;
int $count;
for ($count = 0; $count < $No_of_Cubes; $count ++)
{
polyCube -w 2.50 -h 1 -d 5 ;
move -y .5;
//Trying to create shader - doesn't work
//createAndAssignShader lambert "";
//connectAttr -f lambert2.outColor lambert2SG.surfaceShader;
//sets -e -forceElement lambert2SG;
//displace cubes
move ($count * .5) ($count *.25) 0;
}
}
Hope this helps
Mike