FORUMS: list search recent posts

Adding expression to multiple attributes on multiple objects

COW Forums : Autodesk Maya

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
Steve Stone
Adding expression to multiple attributes on multiple objects
on Jan 29, 2013 at 10:38:43 pm

Hey Guys,
I'm trying to add an expression to sever (40) different spheres. The goal is to have them subtly and smoothly move in postion and subtly and smoothly pulse in scale...all randomly

Currently I've only gotten as far as adding this expression to the translate.X of each object. " = noise(time*3)*.6;" Not only did it take forever, I also realized that I need the values to be random so they don't all move/scale the same. I tried using "=random(1.0)" in the mix (per this post but maya is saying it doesn't recognize "random".

Is there a way to make them random but also apply to all channels of trans and scale at once?

Thanks so much for your time.

Return to posts index

Steve Sayer
Re: Adding expression to multiple attributes on multiple objects
on Mar 1, 2013 at 9:17:08 pm

Hi, Steve.

There isn't an easy way to follow through on your method, but there are a couple of workarounds that might help.

First, if your objects are just meant to be simple spheres, you might look into using a particle system instead of a series of 40 geometry spheres. Particles are much lighter than geometry and it's fairly straightforward to use expressions to get them to change size and position.

However, if you do need to use 40 distinct pieces of geometry, you can write a single expression that will affect all of them. You would use a 'for...' loop and some setAttr commands, and iterate over all your spheres--which would have to be named sequentially (sphere1, sphere2, ... sphere40).

Unfortunately the code for this isn't pretty, and maybe not easy to wrap your head around. It might look something like this:

for ($i = 1; $i <= 40; $i++)
float $s = noise(time + $i);
eval("setAttr sphere"+$i+".scale "+$s+" "+$s+" "+$s);
This will make a series of 40 spheres' scales vary randomly with time. It's a lot less typing, but it's also not very readable. Let me know if you need me to explain it a bit more.

Hope that helps.

Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 All Rights Reserved