rescale / move uv

Hello
I have a lot of 3dpeople, I need to make a "big" texture map with all the people texture maps. That will be done in Photoshop.
I need to place uvs of all 3dpeople in a 12x12 grid (see picture).
I "wrote" a script :
- select one 3dpeople
- run the script
- enter number of division of the grid (here 12)
- enter X and Y position in the grid
It works fine if I change the position once or twice, if I try again and again, it don't work as expected anymore...
Anybody can help ?
Thanks
-------------------------
uv_channel = 1
scale_center = [0,0,0]

try destroyDialog rlslice catch()
global rlslice = rollout rlslice "UV scale/mov"
(

spinner spDIV "DIV " width:90 range:[2,100,12] type:#float pos:[13,15]
button butDIV "GO" width:90 pos:[13,45]
spinner spX "X " width:90 range:[1,100,1] type:#float pos:[13,75]
spinner spY "Y " width:90 range:[1,100,1] type:#float pos:[13,105]
button butMOV "MOV" width:90 pos:[13,135]
on butDIV pressed do
(
DDD = 1 / (spDIV.value)
for node in selection do
(
for v=1 to (polyop.getnummapverts node uv_channel) do
(
pos = polyop.getmapvert node uv_channel v
pos = (pos - scale_center)*[DDD,DDD,1] + scale_center
polyop.setmapvert node uv_channel v pos
)
)
modPanel.addModToSelection (Unwrap_UVW ()) ui:on
maxOps.CollapseNodeTo $ 1 off
)

on butMOV pressed do
(
depl = (1 / spDIV.value)
for node in selection do
(
for v=1 to (polyop.getnummapverts node uv_channel) do
(
pos = polyop.getmapvert node uv_channel v
pos = (pos - scale_center) + [ (spX.value - 1) * depl,(spY.value - 1) * depl,0]
polyop.setmapvert node uv_channel v pos
)
)
modPanel.addModToSelection (Unwrap_UVW ()) ui:on
maxOps.CollapseNodeTo $ 1 off
)

)

createDialog rlslice 120 170
------------------------------------

AttachmentSize
grille_144_01.png15.42 KB