Skip to content

Instantly share code, notes, and snippets.

@rickomax
Created November 28, 2020 17:39
Show Gist options
  • Save rickomax/aba86182b11c4577757460265fea5b82 to your computer and use it in GitHub Desktop.
Save rickomax/aba86182b11c4577757460265fea5b82 to your computer and use it in GitHub Desktop.
MELScript to edit Maya mesh UVs by using values
global proc CreateUI() {
global int $job;
if (`window -ex _uv_window`) {
return;
}
$job = `scriptJob -idleEvent UpdateUI`;
window -t "UV Coordinates Editor" _uv_window;
columnLayout;
rowLayout -numberOfColumns 4;
text "u";
floatField -cc "UpdateU" _uv_uField;
text "v";
floatField -cc "UpdateV" _uv_vField;
setParent ..;
setParent ..;
showWindow;
}
global proc UpdateUI() {
global float $lastUV[];
global float $uv[];
if (!`window -ex _uv_window`) {
scriptJob -ro true -idleEvent KillJob;
return;
}
$uv =`polyEditUV -q`;
if ($uv[0] != $lastUV[0]) {
floatField -e -v $uv[0] _uv_uField;
$lastUV[0] = $uv[0];
}
if ($uv[1] != $lastUV[1]) {
floatField -e -v $uv[1] _uv_vField;
$lastUV[1] = $uv[1];
}
}
global proc UpdateU() {
global float $uv[];
$uv[0] = `floatField -q -v _uv_uField`;
polyEditUV -u $uv[0] -r false;
}
global proc UpdateV() {
global float $uv[];
$uv[1] = `floatField -q -v _uv_vField`;
polyEditUV -v $uv[1] -r false;
}
global proc KillJob() {
global int $job;
scriptJob -k $job;
}
CreateUI();
@rickomax
Copy link
Author

To use the tool, execute the script manually or by adding it to the shelf.
The coordinates window will be updated when a single UV is selected/changed.
Change the values on the coordinates window to change the actual UV coordinates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment