[Closed] maxscript to clone&rotate
i am trying to create a a script to clone an object(instance) and rotate it.
here is the code using listener:-
select $Box$
actionMan.executeAction 0 “40213” – Edit: Clone
instance $ isSelected:n name:“Box#”
$.rotation = quat 0 0 -0.313363 0.949633
what am i doing wrong? did i mention i hav`nt got a clue at maxscript sorry, i just thought it would be easier
Cheers
Hey welcome to the world of maxscript. Here is a sample script that will do what you are asking…at least I think its what you are asking.
(
src = $
newObj = instance src
in coordsys local rotate newObj (eulerangles 45 0 0)
)
Simply copy this script and paste it into a new script and evalute. Currently it will create an instance of your currently selected object and then rotate it on its x-axis 45 degrees. Now this isn’t really much good for you unless you understand what is going on. So here is an explanation:
src = $
this simple assigns the currently selected object a variable (in this case src). This method of using the $ is really not the best or most effective method in larger scripts so I recommend reading up about selections in the maxscript help file.
newObj = instance src
this creates an instance of “src” which is of course your selected object (remember you just assigned the variable to your selected object) and assigns it the variable of “newObj”
in coordsys local rotate newObj (eulerangles 45 0 0)
this rotates your new object in its local coordinate system by 45 degree on its x-axis. The numbrs in the eurlerangles refer to X-axis, Y-axis, Z-axis respectively.
Now that you somewhat understand the script I suggest trying some other things with it. Try makeing a “for loop” so that you can operate on multiple selections, or create multiple selections. Randomize the rotations. I highly recommend that you read up on maxscript with the maxScript help file…it is very good and an excellent resource…
Hope this helps.
In the blurscript collection bspack r42
http://www.blur.com/Tech/blurbeta_plugin_old
you can find RandomTransform.ms that do think very well.
Use it or study it, but surely it does what you want
Thank you so very much
I have gone out and bought the maxscript 101 dvd, and have watch the first half hour, my brain hurts!
again thank you