PDA

View Full Version : Too many deformers!!!


spurv
03-27-2006, 06:13 PM
Hi, im very new to scripting.

My question is:

I have 1 sine deformer, now i whant to connect its offset param. to a expression like this:

sine5.offset = time;

That i know how to do, but if i have 100 deformers in the scene and whant to do the same to all of them? I think i need to use an array.. but how can i do that?

TKS

H3ro
03-27-2006, 06:43 PM
Try this, not sure if it works.


{
//select the deformers
string $sel[] = `ls -sl -fl -l`;

//for every selection, preform task
for ($s in $sel)
//Add expression to control offset
{
expression -s ("" + $s + ".offset = time; ")
-o $s
-ae 1
-uc all ;

}}

spurv
03-27-2006, 06:59 PM
WOWOWOWOW!!! It works!!!
Thankyou !!!

Can you explain it to me?

john_homer
03-27-2006, 10:45 PM
it would be more economical to just connect the time node to the offset..

string $sel[] = `ls -sl -fl -l`;
for ($current in $sel)
{
connectAttr time1.outTime ($current + ".offset");
}

explination...
string $sel[] = `ls -sl -fl -l` // make an array of the selection

for ($current in $sel)
{
}
//for each object in the array do whatever is in the squiggly brackets... the current object in the array will be refered to at $current (in this case)

connectAttr time1.outTime ($current + ".offset");
// connect the outTime of the timeNode (the current frame) to the current objects "offset" attribute.

.j

spurv
03-28-2006, 11:27 AM
john_homer tks for your explenation, now i understand it, but that connection you made connects time directly to the offset so when time is 500 offset is 500, and i dont whant that because sine runs to fast, maybe i could divide it by some, but the expression that H3ro made doesnt do that, when frame is 500 offset is 20. I realy dont understand why.

I think that the offset value is mesured in maya units ("OFFSET Specifies the location of the sine wave relative to the center of the deformer handle").

I apreciate very much the help tou guys gave me.

Tks

spurv
03-28-2006, 11:35 AM
.. sorry but one more question:

now all offsets move at same time, and if i whant to give a diferent movement to each one? How can i do that?

H3ro
03-28-2006, 03:10 PM
You can try adding a random value?

.offset = time + rand(10,10);

rand(min,maxvalue)
Remember all bracets and so on when you add this:)

spurv
03-28-2006, 03:36 PM
.offset = time + rand(10,10);



Ok but this will add a rand (10,10) to all offsets, i would like to do a thing like this:

expression1 : sine1.offset = + rand (10,10)

expression2 : sine2.offset = + rand (13,6)

expression3 : sine3.offset = + rand (6,9)

etc...

So all offsets would have a diferent time or velocity.

H3ro
03-28-2006, 09:13 PM
It did not work at I expected it to do...
Not really sure on how to solve you problem then. I will look some more at it tomrrow, but now its bed time:)

spurv
03-28-2006, 10:15 PM
Tks H3ro, i really need help on this! :)

H3ro
03-31-2006, 12:26 PM
I am at school now, so not really sure if this is some sntax error thing, but try this(cange the $rand value for an other random value:

{
//select the deformers
string $sel[] = `ls -sl -fl -l`;

//for every selection, preform task
for ($s in $sel)
//Add expression to control offset
{
expression -s (" float $rand = rand(10,10);\n " + $s + ".offset = time+$rand; ")
-o $s
-ae 1
-uc all ;

}}

CGTalk Moderation
03-31-2006, 12:26 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.