Random UVW script

I’ve found a script on Scriptspot.com which should allow me to randomise a whole load of UVW mapping. However, my lack of maxscript knowledge is preventing me from editing it to work with Max2009. Could anyone help me with this?

Here’s a link to the script:
http://www.scriptspot.com/3ds-max/nrb-random-uvw

Thanks in advance.

Check the comments below that script posting, you’ll see there’s a 2009 fix and a simpler version :slight_smile:

Hi Colin.
Yes, I did notice the comment, but it is still unclear to me what I need to do. The code that I downloaded, to my eyes, seems to have the change already made, but when I run it, it seems to do nothing.

--------------------------------------------------------------
-- NRB Random UVW
-- By Antero Pedras
-- http://www.neuronblast.com
-- Version : 1.5
-- Modified on: 2001/Nov/24
-- Tested on MAX 4.2
-- Description :This is a simple script that adds to the selected objects a UVW map modifier 
-- and moves the UVW gizmo (on this case a box gizmo) randomly on each object. It's useful 
-- for example when you have many wood doors and want to give them different texture coordinates.
-- For additional documentation go to http://www.neuronblast.com
-- What's new in version  1.5 : progressbar , much faster , collapse stack option
-- To run the script just run it from the maxscript utility . 
-------------------------------------------------------------
utility nrb_uvw "NRB Random UVW"
	(
	groupBox mapping_group " Mapping Gizmo Box " pos:[6,5] width:149 height:97
	label lenght_label "Lenght :" pos:[14,31] width:50 height:15
	label width_label "Width :" pos:[14,55] width:50 height:15
	label height_label "Height :" pos:[14,79] width:50 height:15
	groupBox rndparam_group "Rnd Parameters" pos:[6,110] width:148 height:94
	button newseed_button "new" pos:[107,131] width:39 height:17
	label rndscale_label "Rnd Range :" pos:[51,157] width:61 height:15
	spinner spn_le "" pos:[65,29] width:48 height:16 range:[0,1000,1] type:#worldunits
	spinner spn_wi "" pos:[65,54] width:48 height:16 range:[0,1000,1] type:#worldunits
	spinner spn_he "" pos:[65,79] width:48 height:16 range:[0,1000,1] type:#worldunits
	spinner spn_seed "Seed :" pos:[21,132] width:81 height:16 range:[0,9000,1469]
	spinner spn_from "from :" pos:[20,180] width:60 height:16 range:[-1000,1000,-10] type:#worldunits
	spinner spn_to "to :" pos:[97,180] width:49 height:16 range:[-1000,1000,10] type:#worldunits 
	checkbox chk_collapsernduvw "<-Collapse Stack" checked:false pos:[30,210]
	button uvwall_button "UVW Random Selected" pos:[6,228] width:148 height:21 
	label about_label "www.neuronblast.com" pos:[ 30,250] width:120 height:16
	label datev_label "November 24, 2001 - v1.5" align:#center

	on newseed_button pressed do
		(
		spn_seed.value = random 0.1 9000.0
		)

	on uvwall_button pressed do
		(
		local rnduvwdone
		rnduvwdone=0
		disableSceneRedraw() 
		l= selection
		nobjectos = selection.count
		if nobjectos > 100 then
			(
			perinc =nobjectos/100
			)else
				(
				perinc=100/nobjectos
				)

		progressStart "RND UVW:"
    	progressUpdate rnduvwdone
		vperinc=0
		for i in 1 to nobjectos do
			(
			try(
			addmodifier l[i] (uvwmap())
			l[i].modifiers[1].maptype =4
			l[i].modifiers[1].length= spn_le.value
			l[i].modifiers[1].width= spn_wi.value
			l[i].modifiers[1].height= spn_he.value
			max modify mode
			subobjectlevel=1
			spn_seed.value = random 0.1 9000.0
			seed spn_seed.value
			xrnd = (random spn_from.value spn_to.value)+(random spn_from.value spn_to.value)
			yrnd = (random spn_from.value spn_to.value)+(random spn_from.value spn_to.value)
			zrnd = (random spn_from.value spn_to.value)+(random spn_from.value spn_to.value)
			in coordsys local
			l[i].modifiers[1].gizmo.position = [xrnd ,yrnd,zrnd]
			subobjectlevel=0
            if chk_collapsernduvw.checked==true then collapseStack  l[i]
			max move
			)catch()
			if nobjectos > 100 then
				(
				if vperinc==0 then vperinc=1
				if vperinc<perinc then 
					(
					vperinc=vperinc+1 
					)else
						(
						vperinc=0
						rnduvwdone=rnduvwdone+1
						if rnduvwdone < 100 then progressUpdate rnduvwdone
						)
				)else
					(
					rnduvwdone=rnduvwdone+perinc
					progressUpdate rnduvwdone
					)
			)
	enableSceneRedraw()
    	progressEnd() 
	)		
)

You know it’s a maxscript utility right? So after running it, you go to the utility tab, find the maxscript button, and it is listed in the dropdown menu. After copying your code, running it, and first run of the utility it seemed to work fine for me in 2009.

It appears I have been a moron.

EDIT…having said that, the sript runs, but it doesn’t seem to randomise the UVW mapping. It applies a UVW modifier to each selected object but they are all the same. Did you get this?