UV Render Script : for loop not working

Hello !

I found a simple script on CGSociety that allows to Render an object's uvw template very easily, but I can't get it to work in a for loop : the script renders empty uvw template for each mesh... Any idea ?

Thanks !

Here's the script + the for loop

bakedObject = geometry as array
 
for i in 1 to bakedObject.count do
(
	max modify mode
	--	define Unwrap_UVW modifier
	defUnwrapMod = Unwrap_UVW()
	--	set map chanel to 1
	defUnwrapMod.setMapChannel 1
	--	add Unwrap_UVW modifier to baked object
	addModifier bakedObject[i] defUnwrapMod
	--	define the size of UV template map
	defUnwrapMod.renderuv_width = 2048
	defUnwrapMod.renderuv_height = 2048
 
	defUnwrapMod.renderuv_fillmode = 0
	defUnwrapMod.renderuv_seamColor = green
	defUnwrapMod.renderuv_showframebuffer = on
	defUnwrapMod.renderuv_force2sided = false
	defUnwrapMod.renderuv_fillColor = black
	defUnwrapMod.renderuv_showoverlap = false
	defUnwrapMod.renderuv_overlapColor = red
	defUnwrapMod.renderuv_edgeColor = white
	defUnwrapMod.renderuv_visibleedges = true
	defUnwrapMod.renderuv_invisibleedges = false
	defUnwrapMod.renderuv_seamedges = false	
 
	--	define the path where to store UV template map
	uvSavePath = maxfilepath + bakedObject[i].name + ".jpg"
	uvRenderPath = uvSavePath
	--	render UV template
	defUnwrapMod.renderUV uvRenderPath	
	--	delete Unwrap_UVW modifier
	deleteModifier bakedObject[i] 1	
)