-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathxorig.mel
More file actions
105 lines (89 loc) · 2.36 KB
/
xorig.mel
File metadata and controls
105 lines (89 loc) · 2.36 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
//v0.1c -new- updae() - update attribute editor
//v0.1b fix getOldOrigs() - nurbscurves were not processed corectly
// - delete all ios if no deformers are found
// xorigs
global proc string[] xorig(){
$lssl = `ls -sl`;
string $origs[], $ls_bad_io[];
int $o;
for ($sel in $lssl){
$ios = `ls -dag -io $sel`;
$bad_io = getOldOrigs($sel);
if (size($bad_io)){
$ls_bad_io = stringArrayCatenate($bad_io, $ls_bad_io);
delete $bad_io;
}
else
continue;
$ios = `ls -dag -io $sel`;
$i = 0;
for ($io in $ios){
string $catch = match("Oirg[0-9]{0,2}$", string($io));
if ($catch == "")
continue;
$sfx = "Orig";
if ($i)
$sfx += string($i);
$orig = rename($io, `substitute $catch $io ($sfx)`);
$origs[$o++] = $orig;
$i++;
}
}
updae;
return $ls_bad_io;
}
global proc updae(){
// update attribute editor
if (!`about -b`)
refreshAE;
}
global proc string[] getOldOrigs(string $obj){
// using transform with shapes: mesh, nurbsCurve, nurbsSurface
int $b;
int $good;
string $bad_io[];
$io = `ls -dag -io $obj`;
if (!size(`findRelatedDeformer $obj`))
$bad_io = $io;
$plugs = {
"^1s.w",
// "^1s.i",
// "^1s.cr"
"^1s.o",
"^1s.ws"
};
// $orig = $io[0]
for ($orig in $io){
$good = 0;
for ($plg in $plugs){
$nplg = `format -s $orig $plg`;
if (`objExists $nplg`)
if (size(`listConnections $nplg`)){
$good = 1;
break;
}
}
if (!$good)
$bad_io[$b++] = $orig;
}
return $bad_io;
}
global proc string[] fixOrigs(string $obj){
string $io;
string $organized[];
int $o;
$ios = `ls -dag -io $obj`;
$i = 0;
for ($io in $ios){
string $catch = match("Orig[0-9]{0,2}$", string($io));
if ($catch == "")
continue;
$sfx = "Orig";
if ($i)
$sfx += string($i);
$orig = rename($io, `substitute $catch $io $sfx`);
$organized[$o++] = $orig;
$i++;
}
return $organized;
}