PDA

View Full Version : Maxscript basic question


nazcaLine
05-27-2008, 11:06 PM
hi everybody
i'm just learning maxscript from the very basics. i found a tutorial in which you can move and rotate a collection of objects randomly.this is the script:

for obj in $ do (
randX = random 2.0 4.0
randY = random 2.0 4.0
move obj [randX,randY,0]
randRot=random 0 360
rotRand= eulerangles 0 randRot 0
rotate $ rotRand
)

but when i apply it, it just works for the move, it aassignd different values for every object.however, with rotation and scale it applies the same value to all objects. why is this? why only move works and the other ones not? i tried with primitives and mesh objects, is the same.
if somebody can give me a hand i will really appreciate it, since the start in any matter is always harsh.

thanks in advance.

davestewart
05-27-2008, 11:43 PM
Change rotate $ rotRand to rotate obj rotRand.

$ refers to the entire selection, whereas obj in this case is the iterator that refers to each object in that selection.

Hope that makes sense.
Dave

erilaz
05-27-2008, 11:44 PM
You are using the $ value in your loop rather than the obj value, therefore applying the rotation and scale to all the objects in the selection. Change $ to obj in the loop and you should be fine.

EDIT: You just snuck in there before me Dave! :D

davestewart
05-28-2008, 12:20 AM
2 for the price of 1, then! Not bad at all...

nazcaLine
05-28-2008, 02:32 PM
so that was it! thank you very much!
i,m not very clear yet about the iterator, i'll search in the reference...
i'm actually learning actionscript and the mixture with maxscript is killing me...:)
thank you all!

CGTalk Moderation
05-28-2008, 02:32 PM
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.