ScriptSpot home
Sign in

Script

Shuffle

By Jon Seagull · 2006-10-21

Community reviewsNo reviews yet.
3ds Max compatibility
See listing claims below
How compatibility works

Choose the 3ds Max version you use. For example, selecting 2020 puts direct matches for 2020 first, followed by listings that say a supported version or newer.

Scripts that only mention an older version can still appear as “2020 unconfirmed.” Listings that rule out 2020 are excluded. Use “Show scripts with unconfirmed compatibility” to also see listings without a clear match.

Community reports show what worked for members on a specific release. They’re separate from the listing’s compatibility claims and don’t change the filter.

From original requirements
7, 6, 5, 4
Original version requirement
7; 6; 5; 4
Legacy votes
8
External download
External download

Tags: random

Description

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)

More by Jon Seagull

View all contributions
Comments (12)

herbap · 2018-10-15

huge time saver!

thanks a lot

solution - swap two strings

k2000 · 2013-01-28

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, u contradict o.s.

Anubis · 2013-01-28

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.

2 Anubis - just "uncomment" doesn't work

k2000 · 2013-01-28

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

k2000, we both need to correct yourself

Anubis · 2013-01-29

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)

k2000 · 2013-01-27

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.

rotation

k2000 · 2013-01-26

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

Hi k2000

Anubis · 2013-01-26

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)

k2000 · 2013-01-27

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 "--"

can it shuffle on a line like a spacing tool?:)

crystal3d · 2011-12-09

would be great

vsai · 2008-05-01

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

sergo · 2008-04-11

Marvelous thing!