-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUnitConverter.mel
More file actions
90 lines (80 loc) · 2.35 KB
/
Copy pathUnitConverter.mel
File metadata and controls
90 lines (80 loc) · 2.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
//Unit Converter
//v1.0.1
//author Mitchell Mortenson
//Instructions
/*
1. Copy all code
2. Paste into the Maya script editor under a MEL tab
3. Click 'Execute'
4. (Optional) Click 'Save script to shelf' to save this script to your current shelf
*/
global proc Unit_Converter(){
if(`window -q -ex "Unit_Converter_ui"`)deleteUI("Unit_Converter_ui");
window -t "Unit Converter" "Unit_Converter_ui";
columnLayout -adj true "columnLayout1";
rowLayout -nc 1;
text -l "Width in inches";
rowLayout -p "columnLayout1" -nc 2;
floatField -w 175 -v 1.0 -min 0.0 -pre 4 "floatFieldX";
button -l "Convert to cm" -c "convertUnitsX";
rowLayout -p "columnLayout1" -nc 1;
text -l "Height in inches";
rowLayout -p "columnLayout1" -nc 2;
floatField -w 175 -v 1.0 -min 0.0 -pre 4 "floatFieldY";
button -l "Convert to cm" -c "convertUnitsY";
rowLayout -p "columnLayout1" -nc 1;
text -l "Depth in inches";
rowLayout -p "columnLayout1" -nc 2;
floatField -w 175 -v 1.0 -min 0.0 -pre 4 "floatFieldZ";
button -l "Convert to cm" -c "convertUnitsZ";
button -p "columnLayout1" -l "Convert all to cm" -c convertUnitsAll;
showWindow "Unit_Converter_ui";
}
proc convertUnitsX(){
string $selectedObjs[] = `ls -sl`;
float $oldValueX = `floatField -q -v floatFieldX`;
float $newValueX = `floatField -q -v floatFieldX` * 2.54;
for ($eachX in $selectedObjs){
print $oldValueX;
print "in = ";
print $newValueX;
print "cm";
print "\n";
print "\n";
setAttr ($eachX + ".scaleX") $newValueX;
}
}
proc convertUnitsY(){
string $selectedObjs[] = `ls -sl`;
float $oldValueY = `floatField -q -v floatFieldY`;
float $newValueY = `floatField -q -v floatFieldY` * 2.54;
for ($eachY in $selectedObjs){
print $oldValueY;
print "in = ";
print $newValueY;
print "cm";
print "\n";
print "\n";
setAttr ($eachY + ".scaleY") $newValueY;
}
}
proc convertUnitsZ(){
string $selectedObjs[] = `ls -sl`;
float $oldValueZ = `floatField -q -v floatFieldZ`;
float $newValueZ = `floatField -q -v floatFieldZ` * 2.54;
for ($eachZ in $selectedObjs){
print $oldValueZ;
print "in = ";
print $newValueZ;
print "cm";
print "\n";
print "\n";
setAttr ($eachZ + ".scaleZ") $newValueZ;
}
}
proc convertUnitsAll(){
convertUnitsX;
convertUnitsY;
convertUnitsZ;
}
Unit_Converter();