EXpreSSION quEstioN

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
  02 February 2004
EXpreSSION quEstioN


Hi people,
Im trying to make an expression, but im not so good on it.
I wouyld like to know if someone could help me.
I need to move a bunch of objects at same time, same animation.

example:
Ive a box wich I want to rotate on X..and Ive more 20 boxes called box1, box2, box3, etc...wich I want to be driven by the Box Master..

the expression is this one..

box1.rotateX=Mainbox.rotateX;

but this expression only moves the box1.. My question is, if have a way to type this expression...like

box#`.rotateX=Mainbox.rotateX

and the other boxes move..i dont need to type individuals expressions..

pleaseeeeeeeeeeeeeee
help meeeeeeeeeeeeeeeeeeee

tanx
__________________
:::::>>eDmX<<:::::
www.edmx.com.br

:::EDMX Multimedia Artist:::
 
  02 February 2004
why don't you use connection editor instead?
ALES
 
  02 February 2004
i migth do that..
but i was trying to figure out if with expression could be better..
__________________
:::::>>eDmX<<:::::
www.edmx.com.br

:::EDMX Multimedia Artist:::
 
  02 February 2004
one way would be to wrtite a snippet of code where you loop through writing the expression 20, or however many times is needed.

Quote:
for ($i = 1; $i <= 20; $i++)
expression -s ("box" + $i + ".rotateX = mainBox.rotateX");




Just a basic for loop. The counter, $i, starts at 1 and as long as $i is less than or equal to 20 (or however many boxes you need to add the expression to) it will add an expression to each box. After the expression is written to box$i, $i increases by one ($i++) and as long as $i is still less than or equal to 20, it does it again.

For that code though, they need to be named box1, box2, box3, etc. If you wanted to do it with a selection, you'd have to modify the code a bit.

That code can either be placed within the expression editor, or it could be placed in the script editor and executed with the numPad enter.

Of course, as alesmav said, since you're just making a straight connection, the connection editor might be better. But never fear! You can loop that too!!

Quote:
for ($i = 1; $i <= 20; $i++)
connectAttr mainBox.rotateX ("box" + $i + ".rotateX");



Again with the above loop, you could place it in the expression editor if you want, or you could just run it once from the script editor.

Good luck
__________________
Jared Hromika
www.hromikarenders.com

To me Autokey is like soggy cereal. Sure it's more convenient because you don't have to chew it, but..... ewww. - Keith Lango
 
  02 February 2004
oooo a loopin solution
i might finally finish my script
Henrique BiG ThAnKs FoR CrEaTiN ThAt ThReAd

jHromika thanks for clearin up the loopin thing
__________________

 
  02 February 2004
... or you can just select the objects you want to connect and run the following script.

-------------------------------------------------

string $sel[0] = `ls -sl`;

for ($i = 1; $i < size ($sel); $i++)
connectAttr ($sel[0] + ".rotateX") ($sel[$i] + ".rotateX");

---------------------------------------------------------------------------

Be sure to select the "master" object first.

ALES
 
  02 February 2004
is it possible to create a chain of variables this way? (i mean the above )
like when i first time use the script the all the variables have number 1 in their names and when i use the script the second time they get number 2 in the names?
__________________

 
  02 February 2004
you can also do this in ONE expression:

box20.tx=box19.tx= [...] masterbox.tx ;

where you should continue where the [...] is, next same for ty, tz
or whatever else. (actually it should've been rotate[?] never mind you get the point)

HIH
s.

Last edited by brubin : 02 February 2004 at 11:41 AM.
 
  03 March 2004


hey guys..tanx very much for the answers...
the movie i was making went down...


but tanx a lot for all....


cheers
__________________
:::::>>eDmX<<:::::
www.edmx.com.br

:::EDMX Multimedia Artist:::
 
  01 January 2006
Thread automatically closed

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.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 04:56 PM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.