-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrenhi.mel
More file actions
114 lines (92 loc) · 3.04 KB
/
renhi.mel
File metadata and controls
114 lines (92 loc) · 3.04 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
106
107
108
109
110
111
112
113
114
//v0.1a -upd- renhi(): dorenhi
// -new- dorenhi()
// renames jnts hierarchy
// jnts parent grp, parent grps constriants or
// constraints under joint itself
global proc renikh(){
$lssl = `ls -sl -type ikHandle`;
for ($sel in $lssl){
//$sel = $lssl[0]
string $ls_jn[] = `listConnections ($sel + ".hsj")`;
$bn = `match "[^|]+$" $ls_jn[0]`;
$ikhn = "ikh_" + $bn;
rename $sel $ikhn;
}
}
proc string[] getconstr(string $dagnode){
string $constraints[] = `listRelatives -c -type constraint $dagnode`;
return $constraints;
}
proc fixnames(string $items[], string $bname){
for ($item in $items)
rename $item ($bname + "_" + (`match "[^_]+$" $item`));
}
global proc renhi_(){
$lssl = `ls -sl`;
if (`objectType -i "joint" $lssl[0]`)
if (match("_jnt$*", string($lssl[0])) != "_jnt")
$lssl[0] = `rename $lssl[0] ($lssl[0] + "_jnt#")`;
$ls_par = `listRelatives -p $lssl[0]`;
if (match("_grp$", string($ls_par[0])) == "_grp")
$ls_par[0] = `rename $ls_par[0] ($lssl[0] + "_grp")`;
else if (match("_offset$", string($ls_par[0])) == "_offset")
$ls_par[0] = `rename $ls_par[0] ($lssl[0] + "_offset")`;
else if (match("null[0-9]{0,2}", string($ls_par[0])) != ""){
$ls_par_par = `listRelatives -p $ls_par[0]`;
if (size($ls_par_par) &&
match("_grp$", string($ls_par_par[0])) == "_grp")
$ls_par[0] = `rename $ls_par[0] ($lssl[0] + "_offset")`;
else
$ls_par[0] = `rename $ls_par[0] ($lssl[0] + "_grp")`;
}
$ls_con = `listRelatives -type constraint -c $lssl[0]`;
fixnames($ls_con, $lssl[0]);
$ls_con = getconstr($ls_par[0]);
fixnames($ls_con, $lssl[0]);
}
global proc renhi(){
// string $sel;
$lssl = `ls -sl`;
for ($sel in $lssl){
$res = dorenhi($sel);
// $bname = `match "[^|]+$" $sel`;
// $lspar = `listRelatives -p -f $sel`;
// if (!size($lspar))
// continue;
// tokenize($bname, "_", $split);
// $pfx = $split[0] + "grp";
// $split[0] = $pfx;
// $nn = stringArrayToString($split, "_");
// rename $lspar $nn;
}
}
global proc string dorenhi(string $sel){
string $split[];
$bname = `match "[^|]+$" $sel`;
$lspar = `listRelatives -p -f $sel`;
if (!size($lspar))
return "";
tokenize($bname, "_", $split);
$pfx = $split[0] + "grp";
$split[0] = $pfx;
$nn = stringArrayToString($split, "_");
string $res = `rename $lspar $nn`;
return $res;
}
// fix contraint names
global proc string[] renconstrs(){
string $lssl[] = `ls -sl -type constraint`;
if (!size($lssl)){
$lssl = `ls -type constraint`;
}
string $ls_par[];
for ($sel in $lssl){
$ls_par = `listRelatives -f -p $sel`;
print $ls_par;
$bname = `match "[^|]+$" $ls_par[0]`;
print $bname;
$type = `objectType $sel`;
rename $sel ($bname + "_" + $type);
}
return $lssl;
}