Shuffle

7 votes

Randomly swaps the positions (but not rotation) of selected objects. I use it to save time populating parking lots - by creating groups of identical cars - then running shuffle to get the random distribution.

Additional Info: 

Installation: None (Use MAXScript Menu > Run... to run the script)

Version Requirement: 
7; 6; 5; 4
Video URL: 

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Anubis's picture

k2000, we both need to correct yourself

and after reading this post, I hope you'll see why and that will end this debate ;)

I'm not "swap stings" but Values (Pos/Rot), and I not agree with this statement. The whole difference btw my code and Jon's script is that I use built-in Swap function, that do exactly what it's name say (w/o need of extra coding).

But don't worry, I see what I miss - 1st need to swap #rotation and then #position, so shortly, if you run my commands in swapped order, it s'd work as you expect:

cnt = selection.count
 
for obj in selection do
(swap obj.rotation selection[random 1 cnt].rotation)
 
for obj in selection do
(swap obj.pos selection[random 1 cnt].pos)

my recent MAXScripts RSS (archive here)

k2000's picture

2 Anubis - just "uncomment" doesn't work

just "uncomment" doesn't work properly - all objects loose their places!

I asked this question on maxscript forum - one guy gave me solution

see the link below, it shows what exactly I need
http://clip2net.com/s/2Lchr
cars must shuffle in all parking rows

P.S. I tried your other script strings - that doesn't work for me

P.P.S. uncomment and swap 2 strings - different

Anubis's picture

k2000, u contradict o.s.

first u say "doesn't work" even if not true, then did what I said ("uncomment them"), and now u post the original script with uncommented lines, as u want to looks like u solve it?... very *funny*... and as not see simple "thanks" will consider my future help to you.

my recent MAXScripts RSS (archive here)

k2000's picture

solution - swap two strings

plist = for i in 1 to selection.count collect selection[i].pos
rlist = for i in 1 to selection.count collect selection[i].rotation
for i in selection do
(
local theidx = (random 1 plist.count)
i.rotation = rlist[theidx]
i.pos = plist[theidx]
deleteitem plist theidx
deleteitem rlist theidx
)

now fully working, keeps original object rotation

k2000's picture

found new tool - it can

found new tool - it can replace and keep original rotation
http://www.scriptattack.com/maxscripts/superpainter/superpainter_eng.zip

see my result here
http://clip2net.com/s/2Lchr

just add instances to dialog box
then select all objects you need to replace/swap
and press RS button

Button RS - replaces Selected Objects with Clones of Source objects. Hold Ctrl when pressing to clone only selected in the list source objects. Old objects will be deleted, new clonings will be selected. Clonings inherits position and orientation of replacements, if MRS-transformation are turned on then scripts applies it too. Source objects are impossible to replace, script automatically deselects them when you press RS button.

k2000's picture

I tried that - doesn't

I tried that - doesn't work
that's why author said "no rotation"
i think it's more complex than just a couple of strings and he put "--"

Anubis's picture

Hi k2000

I see that this script already has a lines of code for rotation, you just need to uncomment them by removing "--", or try this:

cnt = selection.count
 
for obj in selection do
(swap obj.pos selection[random 1 cnt].pos)
 
for obj in selection do
(swap obj.rotation selection[random 1 cnt].rotation)

my recent MAXScripts RSS (archive here)

k2000's picture

rotation

can we add option - swap rotation as well?
would be perfect script!!!

crystal3d's picture
vsai's picture

Simple, Effective :) One of

Simple, Effective :) One of those i didn't realize i needed it scripts!

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.