MAXSCRIPT: Move/Scale uv chunks by value

by

Maxscript I wrote  to help myself packing all the atlases from various textures, working on envirnoment jobs. Allows you to easily scale / move uv chunks / groups of them by defined values by clicking a D-PAD like controls. You need to have your UV islands selected for it to work.

A big one:

macroScript scaleUV
category:"_Piro_Tools"
toolTip:"UV: Scale UVs"
buttonText:"Scale UVs"
(
try(destroyDialog rolloutScaleUV )catch()
global scaleToUse = 100
global moveX = 1.5
global moveY = 1.5
global scaleMod = 1
--global scaleFN = 1
fn scaleUV scaleFN howScale=
(
if classof (modPanel.getCurrentObject()) == Unwrap_UVW do
(
try
(
undo "Scale UVWs" on
(
if (howScale == 1) then
(
$.modifiers[#unwrap_uvw].unwrap2.ScaleSelectedXY scaleFN scaleFN [0,0,0]
)
else if (howScale == 2) then
(
$.modifiers[#unwrap_uvw].unwrap2.ScaleSelectedXY scaleFN 1 [0,0,0]
)
else if (howScale == 3) then
(
$.modifiers[#unwrap_uvw].unwrap2.ScaleSelectedXY 1 scaleFN [0,0,0]
)

--selection[1].unwrap_uvw.unwrap2.ScaleSelectedCenter (spnPercent.value/100.0) (rdoAxis.state-1)
)
)
catch
(
messageBox "An unwrap modifier must be the active selection." title:"Didn't Work"
)
)
)

fn moveXfunction moveXFN =
(
if classof (modPanel.getCurrentObject()) == Unwrap_UVW do
(
try
(
undo "Scale UVWs" on
(
print "inside moving function"

--$.modifiers[#unwrap_uvw].unwrap4.SetRelativeTypeIn off
$.modifiers[#unwrap_uvw].unwrap2.moveSelected [moveXFN,0,0]
--selection[1].unwrap_uvw.unwrap2.ScaleSelectedCenter (spnPercent.value/100.0) (rdoAxis.state-1)
)
)
catch
(
messageBox "An unwrap modifier must be the active selection." title:"Didn't Work"
)
)
)

fn moveYfunction moveYFN =
(
if classof (modPanel.getCurrentObject()) == Unwrap_UVW do
(
try
(
undo "Scale UVWs" on
(
print "inside moving function"

--$.modifiers[#unwrap_uvw].unwrap4.SetRelativeTypeIn off
$.modifiers[#unwrap_uvw].unwrap2.moveSelected [0,moveYFN,0]
--selection[1].unwrap_uvw.unwrap2.ScaleSelectedCenter (spnPercent.value/100.0) (rdoAxis.state-1)
)
)
catch
(
messageBox "An unwrap modifier must be the active selection." title:"Didn't Work"
)
)
)


rollout rolloutScaleUV "Scale UVs" width: 170
(



spinner spnPercentA "Percent: " range:[-999,999,50] pos:[10,10]
spinner spnPercentB "Percent: " range:[-999,999,25] pos:[10,30]
spinner spnPercentC "Percent: " range:[-999,999,200] pos:[10,50]
radioButtons rdoAxis "" labels:#("XY","X","Y") default:1 offset:[0,40] pos:[25,70]
button btnScale1 "Scale A" pos:[5,90]
button btnScale2 "Scale B" pos:[55,90]
button btnScale3 "Scale C" pos:[105,90]
spinner spnMoveX "Move tile: " range:[-99,99,0.5] pos:[20,125]
spinner spnMoveY "Move tile: " range:[-99,99,0.5] pos:[20,145]
button moveUp "UP" width:50 height:50 pos:[60, 180]
button moveLeft "LEFT" width:50 height:50 pos:[10, 230]
button moveRight "RIGHT" width:50 height:50 pos:[110, 230]
button moveDown "DOWN" width:50 height:50 pos:[60, 280]
label label1 "..."


on btnScale1 pressed do
(
scaleMod = rdoAxis.state
scaleToUse = spnPercentA.value / 100.0
scaleUV scaleToUse scaleMod
)

on btnScale2 pressed do
(
scaleMod = rdoAxis.state
scaleToUse = spnPercentB.value / 100.0
scaleUV scaleToUse scaleMod
)

on btnScale3 pressed do
(
scaleMod = rdoAxis.state
scaleToUse = spnPercentC.value / 100.0
scaleUV scaleToUse scaleMod
)

on moveLeft pressed do
(
print "MovingLeft"
moveX = (spnMoveX.value * -1.0)
moveXfunction(moveX)
)
on moveRight pressed do
(
print "MovingRight"
moveX = (spnMoveX.value * 1.0)
moveXfunction(moveX)
)

on moveUp pressed do
(
print "MovingLeft"
moveY = (spnMoveY.value * 1.0)
moveYfunction(moveY)
)
on moveDown pressed do
(
print "MovingRight"
moveY = (spnMoveY.value * -1.0)
moveYfunction(moveY)
)
)

createDialog rolloutScaleUV
)

 

As always, you'll find it here: