PDA

View Full Version : Random Spheres Script Creator


shenmue
05-19-2007, 06:25 PM
Hi guys

I am learning Mel script,and I am starting to create my scripts...well,actually trying to create scripts :rolleyes:
I am doing basic stuff.In this script I try to create a sphere random generator based on the value on the intField.So I create the UI,but when I call the procedure from the button "create Balls" I am running in to that problem :
// Error: Line 1.16: Wrong number of arguments on call to CreateRudiBalls. //

I donŽt know what I am missing.Can you help me please?
Here is the code.Thanks


if (`window -q -ex "rudiBallsCreator_W"`) deleteUI "rudiBallsCreator_W";
window -t "Rudi Balls Creator" "rudiBallsCreator_W";
rowLayout -nc 2 -columnWidth2 125 100 "sphereCreator_RL";
button -l "create Random Balls" -c "CreateRudiBalls";
intField "ballIntField";

$ballsNumber = `intField -q -value "ballIntField"`;

global proc CreateRudiBalls (int $ballsNumber)

{

for ($i=0;$i<=$ballsNumber;$i++)
{
float $randomRadius =`rand 0.5 5`;
float $randomPosX = `rand 0 20`;
float $randomPosY = `rand 0 20`;
float $randomPosZ = `rand 0 20`;

polySphere -r $randomRadius;
move -r -os -wd $randomPosX $randomPosY $randomPosZ;
}
}

showWindow;

tbaypaul
05-19-2007, 07:17 PM
I think it is because you aren't passing anything to your creator function....you query the button before it is ever created at the bottom of the script in showWindow.....stick the int query into the procedure and that will be fetched by the creator.....

shenmue
05-19-2007, 09:58 PM
thanks man.IŽll keep trying.But I havenŽt fixed it yet.mmm...:shrug:
what am I missing....IŽll tell you guys if it finally find what is wrong.

Sick Spider
05-19-2007, 10:40 PM
There you go:

if (`window -q -ex "rudiBallsCreator_W"`) deleteUI "rudiBallsCreator_W";
window -t "Rudi Balls Creator" "rudiBallsCreator_W";
rowLayout -nc 2 -columnWidth2 125 100 "sphereCreator_RL";
button -l "create Random Balls" -c "CreateRudiBalls";
intField "ballIntField";

$ballsNumber = `intField -q -value "ballIntField"`;
showWindow;
global proc CreateRudiBalls()

{
int $ballsNumber = `intField -q -v "ballIntField"`;

for ($i=0;$i<=$ballsNumber;$i++)
{
float $randomRadius =`rand 0.5 5`;
float $randomPosX = `rand 0 20`;
float $randomPosY = `rand 0 20`;
float $randomPosZ = `rand 0 20`;

polySphere -r $randomRadius;
move -r -os -wd $randomPosX $randomPosY $randomPosZ;
}
}

The query of how namy balls i moved INTO the actuall proc'.
You had proc XxX(giveValue).
when actually in the button u just calld the proc withOUT giving in any value, thats why u got the error.

shenmue
05-19-2007, 11:22 PM
hey sickSpider!
Damn!I just found the solution and I was just going to put it when I saw your reply!:D lol
Thanks man.I have been 1 hour looking for the problem and I did the exact thing you did.
Next time IŽll be faster!:)

Moving on to the next:Loops with While-Do(I know I know...newbie stuff)

CGTalk Moderation
05-19-2007, 11:22 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.