PDA

View Full Version : desperate trying to create particles and fields with a script.


a6u5t
12-20-2007, 07:08 AM
Can someone please help me with my script; Maya says Error without anymore explanation. I'm trying to create a particle and a field, with the script. I've added notes where the possible problem is likely to occur. (2 of them, I think). Would appreciate any help, I'm not a programmer.



global proc asParticlesFields4 ()
{
string $winName = ` window -title "Particles and Fields" `;
columnLayout;


text -label "Playback Range";
intField playback;

text -label "EMITER";
text -label "Rate";
floatSliderGrp -field true rate;

text -label "Speed";
floatSliderGrp -field true speed;

text -label "Speed random";
floatSliderGrp -field true speedR;

//possible problem1//
string $groupR1 = `radioButtonGrp -numberOfRadioButtons 4 - label "What kind of FIELDS?" -labelArray4 "Newton" "Radial" "Turbulence" "Vortex" which `;
radioButtonGrp -numberOfRadioButtons 4 -shareCollection $groupR1 -label "" -labelArray4 "Air" "Drag" "Gravity" "Uniform" which2;
radioButtonGrp -numberOfRadioButtons 2 -shareCollection $groupR1 -label "" -labelArray2 "Volume Axis" "No Fields" which3;

text -label "Magnitude";
floatSliderGrp -field true magnitude;

text -label "Attenuation";
floatSliderGrp -field true attenuation;


button -label "Execute" -command "testIt3()";



showWindow $winName;
}

global proc testIt3()
{

int $playrange = `intField -query -value playback `;
float $rat = ` floatSliderGrp -query -value rate `;
float $sped = ` floatSliderGrp -query -value speed `;
float $spedr = ` floatSliderGrp -query -value speedR `;

//possible problem 2//
int $whichFields = ` radioButtonGrp -query -select which1 which2 which3 `;


float $mag = ` floatSliderGrp -query -value magnitude `;
float $att = ` floatSliderGrp -query -value attenuation `;


playbackOptions -minTime 0 -maxTime $playrange;

string $theEmitter[] = ` emitter -pos 0 0 0 -type omni -r $rat -speed $sped -speedRandom $spedr `;

string $parBucket[] = ` particle `;

connectDynamic -em emitter1 particle1;

select -clear;


switch ($whichFields)
{
case 1:
string $theFields[] = ` newton -m $mag -att $att `;
select -clear;
connectDynamic -f newtonFields1 particle1;
break;
case 2:
string $theFields[] = `radial -m $mag -att $att `;
break;
case 3:
string $theFields[] = `turbulence -m $mag -att $att `;
break;
case 4:
string $theFields[] = `vortex -m $mag -att $att `;
break;
case 5:
string $theFields[] = `air -m $mag -att $att `;
break;
case 6:
string $theFields[] = `drag -m $mag -att $att `;
break;
case 7:
string $theFields[] = `gravity -m $mag -att $att `;
break;
case 8:
string $theFields[] = `uniform -m $mag -att $att `;
break;
case 9:
string $theFields[] = `volumeAxis -m $mag -att $att `;
break;
case 10:
break;

}
}

isoparmB
12-20-2007, 10:27 AM
string $groupR1 = `radioButtonGrp -numberOfRadioButtons 4 - label "What kind of FIELDS?" -labelArray4 "Newton" "Radial" "Turbulence" "Vortex" which1 `;

Your script was referring to "which1", while one of your radioButtonGrps was just named "which", hence maya was looking for a non-existant UI element. I renamed your "which" to "which1", and your script worked.

a6u5t
12-20-2007, 12:06 PM
Thanks for the help isoparmB!

Been working too much lately. Can't believe I overlooked that tiny mistake; thanks for the fresh eyes. ;-) But the thing is about the 2nd problem:

//possible problem 2//
int $whichFields = ` radioButtonGrp -query -select which1 which2 which3 `;

Is that a correct use of code? So, I'm making radioButtons, 10 options to be exact. RadioButtons can only do 4 options each, so I use the -shareCollection flag. I don't know how I should go about query-ing (obtain-ing the option that users choose) from 10 radioButtons. This code is definitely not working because no fields is made (the fields show when you choose option 1 through 4, but not from 5-10; moreover, when the fields show when you choose 1-4 it doesn't affect the particles.) So weird.

Please some help, 16 hours to deadline.

Derek Wolfe
12-20-2007, 08:55 PM
Does this work how you want it to? There is likely a better way to do it, but this'll get you through your deadline.


global proc asParticlesFields4 ()

{

string $winName = ` window -title "Particles and Fields" `;

columnLayout;



text -label "Playback Range";

intField playback;

text -label "EMITER";

text -label "Rate";

floatSliderGrp -field true rate;

text -label "Speed";

floatSliderGrp -field true speed;

text -label "Speed random";

floatSliderGrp -field true speedR;

//possible problem1//

string $groupR1 = `radioButtonGrp -numberOfRadioButtons 4 - label "What kind of FIELDS?" -labelArray4 "Newton" "Radial" "Turbulence" "Vortex" which1 `;

radioButtonGrp -numberOfRadioButtons 4 -shareCollection $groupR1 -label "" -labelArray4 "Air" "Drag" "Gravity" "Uniform" which2;

radioButtonGrp -numberOfRadioButtons 2 -shareCollection $groupR1 -label "" -labelArray2 "Volume Axis" "No Fields" which3;

text -label "Magnitude";

floatSliderGrp -field true magnitude;

text -label "Attenuation";

floatSliderGrp -field true attenuation;



button -label "Execute" -command "testIt3()";





showWindow $winName;

}

global proc testIt3()

{

int $playrange = `intField -query -value playback `;

float $rat = ` floatSliderGrp -query -value rate `;

float $sped = ` floatSliderGrp -query -value speed `;

float $spedr = ` floatSliderGrp -query -value speedR `;

//possible problem 2//

int $whichFields = 0;

int $whichFields = ` radioButtonGrp -query -select which1 `;

if($whichFields == 0){

$whichFields = ` radioButtonGrp -query -select which2 `;

if($whichFields == 0){

$whichFields = ` radioButtonGrp -query -select which3 `;

$whichFields += 4;

}

$whichFields += 4;

}

float $mag = ` floatSliderGrp -query -value magnitude `;

float $att = ` floatSliderGrp -query -value attenuation `;



playbackOptions -minTime 0 -maxTime $playrange;

string $theEmitter[] = ` emitter -pos 0 0 0 -type omni -r $rat -speed $sped -speedRandom $spedr `;

string $parBucket[] = ` particle `;

connectDynamic -em emitter1 $parBucket[0];

select -clear;



switch ($whichFields)

{

case 1:

string $theFields[] = ` newton -m $mag -att $att `;

select -clear;

connectDynamic -f $theFields[0] $parBucket[0];

break;

case 2:

string $theFields[] = `radial -m $mag -att $att `;

connectDynamic -f $theFields[0] $parBucket[0];

break;

case 3:

string $theFields[] = `turbulence -m $mag -att $att `;

connectDynamic -f $theFields[0] $parBucket[0];

break;

case 4:

string $theFields[] = `vortex -m $mag -att $att `;

connectDynamic -f $theFields[0] $parBucket[0];

break;

case 5:

string $theFields[] = `air -m $mag -att $att `;

connectDynamic -f $theFields[0] $parBucket[0];

break;

case 6:

string $theFields[] = `drag -m $mag -att $att `;

connectDynamic -f $theFields[0] $parBucket[0];

break;

case 7:

string $theFields[] = `gravity -m $mag -att $att `;

connectDynamic -f $theFields[0] $parBucket[0];

break;

case 8:

string $theFields[] = `uniform -m $mag -att $att `;

connectDynamic -f $theFields[0] $parBucket[0];

break;

case 9:

string $theFields[] = `volumeAxis -m $mag -att $att `;

connectDynamic -f $theFields[0] $parBucket[0];

break;

case 10:

break;

}

}

asParticlesFields4;

CGTalk Moderation
12-20-2007, 08:55 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.