Wednesday 18 March 2009

If Statements

Hi Nick

We are having problems with 'if' statements.  What we want to do is set up an expression which will determine the positioning of an object in relation to the range of values which we have set.  For example, if (sensorvalue) is less than or equal to x, AND more than or equal to y THEN position the object at position z.

Here are the expressions we have tried which aren't working!:

1.

if ((sensorInput.sensor3<=300)&&(sensorInput.sensor3>=250))
{
select -r pCube1;
move -r 50 0 0;
}

2.

if ((sensorInput.sensor3<=300)&&(sensorInput.sensor3>=250))
{
pCube1.translateY = 50
}



Any ideas?

Thanks

Mark

Wednesday 11 March 2009

script from today

for($i=0;$i<=20;$i++)
{
polySphere -ch on -o on -r $i ;
}

///////////////////////////////////
//change the number it counts by
for($i=0;$i<=20;$i+=2)
{
polySphere -ch on -o on -r $i ;
}

///////////////////////////////////
//count backwards
for($i=20;$i>=0;$i-=1)
{
polySphere -n ("ball_"+$i) -ch on -o on -r $i ;
move -a $i 0 0 ("ball_"+$i);
}
////////////////////////
///////////////////////////////////
//using names
for($i=0;$i<=20;$i++)
{
polySphere -n ("ball_"+$i) -ch on -o on -r $i ;
move -a $i 0 0 ("ball_"+$i);
}
///////////////////////////////////
//adding multiplier
for($i=0;$i<=20;$i++)
{
polySphere -n ("ball_"+$i) -ch on -o on -r $i ;
move -a ($i*5) 0 0 ("ball_"+$i);
}

///////////////////////////////////
//move scale rotate
for($i=0;$i<=20;$i++)
{
string $name = ("ball_"+$i);
polySphere -n $name-ch on -o on -r $i ;
move -a 0 ($i*5) 0 $name;
rotate -a 0 ($i*10) 0 $name;
scale -a 1 1 ($i*3) $name;
}
///////////////////////////////////
//move scale rotate make more
for($i=0;$i<=200;$i++)
{
string $name = ("ball_"+$i);
polySphere -n $name-ch on -o on -r $i ;
move -a 0 ($i*5) 0 $name;
rotate -a 0 ($i*10) 0 $name;
scale -a 1 1 ($i*0.01) $name;
}

///////////////////////////////////
//move scale rotate make more with variables
int $total = 200;
float $moveFactor = 5;
float $rotateFactor = 10;
float $scaleFactor = 0.01;
for($i=0;$i<=$total;$i++)
{
string $name = ("ball_"+$i);
polySphere -n $name-ch on -o on -r $i ;
move -a 0 ($i*$moveFactor) 0 $name;
rotate -a 0 ($i*$rotateFactor) 0 $name;
scale -a 1 1 ($i*$scaleFactor) $name;
}
///////////////////////////////////////////////
//2d sin curve
int $totalBoxes = 300;
float $sinMultiply = 5;
float $zFactor = 1.2;
for($x=1;$x<=$totalBoxes;$x++)
{
float $xMove = sin($x);
string $whateverYouWant = ("box_"+$x);
polyCube -n $whateverYouWant;
move -a ($xMove*$sinMultiply) 0 ($x*$zFactor) $whateverYouWant;
}
///////////////////////////////////////////////
//3d sin curve
int $totalBoxes = 300;
float $sinMultiply = 5;
float $zFactor = 2;
for($x=1;$x<=$totalBoxes;$x++)
{
float $xMove = sin($x);
string $whateverYouWant = ("box_"+$x);
polyCube -n $whateverYouWant;
move -a ($xMove*$sinMultiply) ($xMove*$sinMultiply) ($x*$zFactor) $whateverYouWant;
}

//////////////////////////////////////////////////
//connect to input
int $totalBoxes = 30;
float $zFactor = 1.2;
for($x=1;$x<=$totalBoxes;$x++)
{
string $whateverYouWant = ("box_"+$x);
string $expText = ("box_"+$x+".translateY = sensorInput.sensor1*"+($x*10));
polyCube -n $whateverYouWant;
move -a 0 0 ($x*$zFactor) $whateverYouWant;

expression -s $expText -o box_1 -ae 1 -uc all ;
}
/////////////////////////////////////
//connect to input expression different
int $totalBoxes = 30;
float $zFactor = 1.2;
for($x=1;$x<=$totalBoxes;$x++)
{
string $whateverYouWant = ("box_"+$x);
string $expText = ($whateverYouWant+".translateY = sensorInput.sensor1*"+($x*10));
polyCube -n $whateverYouWant;
move -a 0 0 ($x*$zFactor) $whateverYouWant;

expression -s $expText -o box_1 -ae 1 -uc all ;
}
/////////////////////////////////////
//connect to input expression sinWave
int $totalBoxes = 30;
float $zFactor = 1.2;
for($x=1;$x<=$totalBoxes;$x++)
{
float $sinWave = sin($x);
string $whateverYouWant = ("box_"+$x);
string $expText = ($whateverYouWant+".translateY = sensorInput.sensor1*"+($sinWave*10));
polyCube -n $whateverYouWant;
move -a 0 0 ($x*$zFactor) $whateverYouWant;

expression -s $expText -o box_1 -ae 1 -uc all ;
}
/////////////////////////////////////
//connect to input expression sinWave increasing
int $totalBoxes = 200;
float $zFactor = 1.2;
for($x=1;$x<=$totalBoxes;$x++)
{
float $sinWave = sin($x);
string $whateverYouWant = ("box_"+$x);
string $expText = ($whateverYouWant+".translateY = sensorInput.sensor1*"+($sinWave*$x));
polyCube -n $whateverYouWant;
move -a 0 0 ($x*$zFactor) $whateverYouWant;

expression -s $expText -o box_1 -ae 1 -uc all ;
}

Thursday 5 March 2009

Problem with ''Add attribute''

Hi Nick

I have a problem with adding an attribute to an object in Maya. Unfortunately it doesn’t deem to work for me.
What I do is: click on the object / from properties – add attribute – name-- leave it on the float option / ok

Then I manually change a property for example ‘’rotation’’ or ‘’x-y-z translation’’.

Then from the script editor I copy and paste the commands as you advised.

When I try to test it does not work.

Why do you think this happens? Is it something I do wrong? I remember yesterday you have tried as well on my pc and it did not work either.

Any advise please?

Many thanks

Maria