Random X,Y,Z positions on multiple objects at one time?

Random X,Y,Z positions on multiple objects at one time?

Anonymous
Not applicable
4,521 Views
2 Replies
Message 1 of 3

Random X,Y,Z positions on multiple objects at one time?

Anonymous
Not applicable
I'm working on a project where I have a multiple columns of poly cubes (over 300) that I want to position in a random X,Y,Z. I've tried through MEL & expressions, but I'm unsuccessful. I can move 1 cube using expressions & MEL, but I want to do it to all of them at the same time. All my object are name polyplane(1 through 365).
0 Likes
4,522 Views
2 Replies
Replies (2)
Message 2 of 3

Anifex09
Collaborator
Collaborator
You need to take some time to learn MEL. Think of it as everything you do in Maya is using MEL to execute your actions. Look up FOR statement and Selection Arrays. You can use MEL to find all the objects selected and the number of objects selected. You than execute a For statement that randomly reposition object in the selection array. One of the big selling points to using Maya is MEL.
0 Likes
Message 3 of 3

Anonymous
Not applicable
string $selectedList[] = `ls -sl`;
string $currentObject;

for ($currentObject in $selectedList)
{
setAttr ($currentObject + ".translateX") (rand(-10,10));
setAttr ($currentObject + ".translateY") (rand(-10,10));
setAttr ($currentObject + ".translateZ") (rand(-10,10));
}

////change the values in the rand section to determine
////the min and max values your objects can go