Inside Sabertooth
Learn how Sabertooth uses 3ds Max to create 3D interactive projects, including HBO Go’s Game of Thrones interactive experience
  • 1/3
You are here: Forum Home / Autodesk® Maya® / MEL / Random X,Y,Z positions on multiple objects at one time?
  RSS 2.0 ATOM  

Random X,Y,Z positions on multiple objects at one time?
Rate this thread
 
52110
 
Permlink of this thread  
avatar
  • Location: Oklahoma City, OKlahoma
  • Total Posts: 7
  • Joined: 15 November 2010 10:00 PM

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).



Kevin B.

Replies: 1
/userdata/avatar/g6mvry9w7_IMG_0417.jpg

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.

Author: RROCHS

Replied: 07 February 2011 11:59 PM  
avatar
  • johnnyz
  • Posted: 03 May 2011 08:32 AM

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



Replies: 0