# How to access each vertex of a polyCube and move it randomly??

 06 June 2009 FireSkull New Member portfolio FireSkull MN, USA How to access each vertex of a polyCube and move it randomly?? Hi MEL Masters, I have a query for all MEL experts. I am new to MEL, so I am in a learning phase right now. The problem is that I have created a polyCube in Maya. Like all cubes, it has 8 vertices. What I'm trying to do is that I want each and every vertex of the polyCube to move at a random X,Y,Z position thereby creating a deformed cube. The solution in my mind is that first i create three variables as; float \$Xpos = rand(-12,12) float \$Ypos = rand(-12,12) float \$Zpos = rand(-12,12) and then assign these variables as X,Y,Z position of each vertex like; move \$Xpos \$Ypos \$Zpos; I understand that for this I have to use the for() loop so that each time a distorted cube is created it will have a different shape. Finally i will make a procedure that will accept the number of distorted cubes as input form the user and gives the result. Something like; global proc CreateDistortedCubes(int \$NoOfCubes) If anyone can write me a MEL for this or at least give me a clue in the form of a chunk of code, i'll be greatful. I can handle the for() loop on my own. I just want to know how to access each vertex of a polyCube through MEL, and move each vertex dynamically through rand() command. Thank you. share quote
 06 June 2009 mlefevre Expert   ... United Kingdom Hi, Here's a crude example. You might want to mess about with the move command flag, -relative & -absolute. You could also load the procedure into memory, and place distortObj(-1, 1) in an expression to get some random animation going. Should work for any number of objects selected. `````` global proc distortObj(float \$randomA, float \$randomB) { float \$Xpos; float \$Ypos; float \$Zpos; string \$sel[] = `ls -sl`; int \$vtxCount[]; int \$k = 0; for (\$each in \$sel) { int \$vtxInfo[] = `polyEvaluate -vertex \$each`; \$vtxCount[\$k] = \$vtxInfo[0]; \$k++; } for (\$i=0;\$i
 06 June 2009 FireSkull New Member portfolio FireSkull MN, USA Thanks Hey it worked. Thank you so much. I owe you bro.. Can I have your email address?? share quote
 06 June 2009 CGTalk Moderation Expert 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. share quote

 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 vBulletinCopyright ©2000 - 2006, Jelsoft Enterprises Ltd.