# Translating group of cubes individually in the y direction..

 11 November 2007 coolman85 New Member Ramy Electrical Engineer - VFX beginner Gilgamesh Amman, Jordan Translating group of cubes individually in the y direction.. hey guys .. can u please help me out ? i need to move set of cubes in the y direction like from 10 to 0, cube after cube ... so thnx to ur site i came out with this script: string \$cubes[] = `ls -sl`; select \$cubes[0]; for(\$i=0;\$i<=10;\$i++){ for(\$k=0;\$k<=1000;\$k+=100){ setKeyframe -t (\$k) -v 10 -at ty \$cubes[\$i]; setKeyframe -t (\$k+70) -v 0 -at ty \$cubes[\$i]; }} but it moves the whole group together ... can u please tell me y ?? thnx in advance share quote
 11 November 2007 Gnimmel Expert Richard Cheek Technical animator Freelance-Animation USA You are looping through each cube and setting keyframes between frames 0 and 1000 on all of them the same, so they will all move the same. You also get the cubes by listing selected and then forcing the cube loop to 10. If you only select 5 cubes this script will error. If all you are trying to do is move the cubes from 10 to 0, one after the other, then you only need one loop. Looking at your script you seem to be moving the cubes from 10 to 0 over 70 frames. One way to do this would be to loop through the cube list and have your \$k var update after each loop. Somthing like; string \$cubes[] = `ls -sl`; string \$EachCube; float \$k= 0; for(\$EachCube in \$cubes) { setKeyframe -t \$k -v 10 -at ty \$EachCube ; setKeyframe -t (\$k + 70) -v 0 -at ty \$EachCube ; \$k+= 70; }; Thanks, Richard __________________ Richard Cheek http://www.freelance-animation.com Personal project : The Goblin Abyss share quote
 11 November 2007 coolman85 New Member Ramy Electrical Engineer - VFX beginner Gilgamesh Amman, Jordan thnx Richard .. the script worked pretty well & believe it or not i spent bout 6 hours tryin to figure out how to make it & i reached the point that i sent u ... well 1 thing i'd like to mention that in ur script 2nd line there's (string \$EachCube isn't the "string" command workin with "[]"? pardon me am sort of beginner in MEL... & "for(\$EachCube in \$cubes)" couldn't i use the loop command "for(\$i=0;\$i<=9;\$i++) to loop through the cubes[] string ? know that i'd selected all the 10'th cubes b4 running the script .. sorry 4 askin to many but i just wanted to get things right ... thnx 4 ur afforts .. god blesses. share quote
 11 November 2007 Gnimmel Expert Richard Cheek Technical animator Freelance-Animation USA The second line: string \$EachCube; is just to declare the varible as a string before I use it. MEL can work out what type varibles should be without declairing, but I've ran into a few problems with this where I wanted a float and it declaired a int, so I always declair stuff before using it. Yes you could use for(\$i=0;\$i<=9;\$i++) instead of for(\$EachCube in \$cubes), but that limits you to a pre set amount of cubes. It sounds like in your case all you need is 10 cubes so it really doesn't matter here, either way would work. Thanks, Richard __________________ Richard Cheek http://www.freelance-animation.com Personal project : The Goblin Abyss share quote
 11 November 2007 coolman85 New Member Ramy Electrical Engineer - VFX beginner Gilgamesh Amman, Jordan thnx alot man .. i really appreciate ur time .. by the way i have more than 4000 cubes to move in this script so thnx 4 ur help..next thing i tried to make & i couldn't is to make the transparency of these cubes = 1 when they'r lets say above y=5 & equals 0 below 1 but it didn't work either .. take a look if u can & i'll tell u wut happend 2 me: string \$cubes[] = `ls -sl`; for (\$i = 0; \$i<=9; \$i++){ float \$position = `getAttr (\$cubes[\$i] + ".ty")`; if (\$position >=10){ setAttr "shader.transparency" 1;} else{ setAttr "shader.transparency" 0;} } so applied a new blinn shader to all the cubes & renamed it "shader" .. b4 i put the " setAttr "shader.transparency" 1;" command i used different print commands in the both conditions & worked properly but when it comes to the shader it didn't work .. can u tell me plz ? thnx again man .. share quote
 11 November 2007 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.