-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmdl_tools.mel
More file actions
89 lines (83 loc) · 2.47 KB
/
mdl_tools.mel
File metadata and controls
89 lines (83 loc) · 2.47 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
//0.1b -new- getuvtex(), setuvtex()
//0.1a -new- doPairedBlendShape - creates blendshape
// on given paired list(paris:0-1, 2-3..etc)
//cleanIsolatedComps("geo")
global proc int cleanIsolatedComps(string $root){
/* Clean unused vertices, edges on meshes
Returns: false(0) on success
Usage: cleanIsolatedComps "original";
*/
string $f_items[]; // failed items
string $all_mesh[] = `listRelatives -f -ad -c -type mesh $root`;
int $sz = `size $all_mesh`;
int $w, $f; // washed, failed counters
for ($se in `listRelatives -f -p $all_mesh`){
print {" poly washing: " + $se};
$res = catchQuiet(
`polyClean -ch 0
-cleanVertices 1
-cleanEdges 1
-cleanPartialUVMapping 0
$se`
);
if ($res)
$f_items[$f++] = $se;
else
$w++;
}
print (`format -s $sz -s $w "| Processed: ^2s/^1s\n"`);
print (`format -s $sz -s $w "| Failed:\n"`);
print $f_items;
return ($sz != $w);
}
global proc string[] doPairedBlendShape(
string $lssl[]){
// lssl - paired list array:
// 0 - target, 1 - source(child)
if (!size($lssl)){
$lssl = `ls -sl`;
}
string $items[];
$b = 0;
string $src, $trg;
for ($i=0; $i<size($lssl); $i++){
$src = $lssl[$i++];
$trg = $lssl[$i];
// help blendShape
$bs_data = `blendShape -en 1 -w 0 1 $src $trg`;
print $bs_data;
$items[$b++] = $bs_data[0];
}
return $items;
}
global proc getuvtex(){
// get uv texel for selected uv
global float $gBaUVtex;
$map_sz = `optionVar -q polyUVTexelDensityMapSize`;
$gBaUVtex = `texGetTexelDensity $map_sz`;
headsUpMessage -uve 1 $gBaUVtex;
}
global proc setuvtex(){
// set texel density for selected uv
global float $gBaUVtex;
$map_sz = `optionVar -q polyUVTexelDensityMapSize`;
$_usr = `promptDialog -tx $gBaUVtex`;
if ($_usr != "dismiss"){
float $val = `promptDialog -q -tx`;
print $val;
texSetTexelDensity $val $map_sz;
$gBaUVtex = $val;
}
}
global proc pcomb(){
// combine to last selected geometry
string $lssl[] = `ls -sl`;
$ls_sz = size($lssl);
$trg = $lssl[$ls_sz-1];
$bn = `match "[^|]+$" $trg`;
$ls_par = `listRelatives -f -p $trg`;
$combined = `polyUnite -ch 0 -op`;
if (size($ls_par))
parent $combined[0] $ls_par[0];
rename $combined[0] $bn;
}