Maya Programming
Welcome to Autodesk’s Maya Forums. Share your knowledge, ask questions, and explore popular Maya SDK topics.
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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

Message 1 of 3
3938 Views, 2 Replies

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

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).
Message 2 of 3
in reply to: Anonymous

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.
Message 3 of 3
in reply to: Anonymous

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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators

Autodesk Design & Make Report