-
Notifications
You must be signed in to change notification settings - Fork 0
/
cometAttrEditor.mel
executable file
·173 lines (136 loc) · 4.46 KB
/
cometAttrEditor.mel
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
// --------------------------------------------------------------------------
// cometAttrEditor.mel - MEL Script
// --------------------------------------------------------------------------
//
// DESCRIPTION:
// A util for dealing with some attribute stuff.
//
// REQUIRES:
// Nothing.
//
//
// USAGE:
// source "cometAttrEditor.mel"; cometAttrEditor();
//
// AUTHORS:
// Michael B. Comet - comet@comet-cartoons.com
// Copyright ©2004 Michael B. Comet - All Rights Reserved.
//
// VERSIONS:
// 1.00 - Aug 27, 2004 - Initial Release.
//
// --------------------------------------------------------------------------
/*
* cometAttrEditor() - Main Entry
*/
global proc cometAttrEditor()
{
if (`window -q -ex cometAttrEditorWin`)
{
showWindow cometAttrEditorWin ;
return ;
}
window -w 230 -h 60 -t "Comet Attr. Editor - 1.00" cometAttrEditorWin ;
formLayout mainForm ;
button -l ("Move UP") -c ("cAE_moveAttrs(0)") -ann ("Slide selected channelBox attributes up.") btnUp ;
button -l ("Move DOWN") -c ("cAE_moveAttrs(1)") -ann ("Slide selected channelBox attributes down.") btnDown ;
formLayout -e
-af btnUp "top" 5
-an btnUp "bottom"
-af btnUp "left" 5
-ap btnUp "right" 0 50
-af btnDown "top" 5
-an btnDown "bottom"
-ap btnDown "left" 0 50
-af btnDown "right" 5
mainForm ;
showWindow cometAttrEditorWin ;
}
// --------------------------------------------------------------------------
/*
* cAE_moveAttrs() - Adjust attrs
*/
global proc cAE_moveAttrs(int $dir)
{
// What objs and attrs are highlighted in the channel box?
string $cbObjs[] = `channelBox -q -mol mainChannelBox` ;
string $cbAttrs[] = `channelBox -q -sma mainChannelBox` ;
int $i;
string $obj ;
for ($obj in $cbObjs)
{
if ($dir == 0) // Work top to bottom if moving up
{
for ($i=0; $i < size($cbAttrs); ++$i)
cAE_moveAttr($obj, $cbAttrs[$i], $dir) ;
}
else if ($dir == 1) // Work bottom to top moving down
{
for ($i=size($cbAttrs)-1; $i >= 0; --$i)
cAE_moveAttr($obj, $cbAttrs[$i], $dir) ;
}
// Must do this or channel box won't refresh.
string $sel[] = `ls -sl -l`;
select -cl ;
refresh ;
select -r $sel ;
}
}
// --------------------------------------------------------------------------
/*
* cAE_moveAttr() - Adjust one attr specified up or down.
* $dir: 0=up 1=down
*/
global proc cAE_moveAttr(string $obj, string $attr, int $dir)
{
string $udAttrs[] = `listAttr -ud $obj` ; // Get just user defined ones.
int $i ;
// First find out where in the order of all the user defined attrs this one is.
int $idx = -1 ;
for ($i=0; $i < size($udAttrs); ++$i)
{
if ($udAttrs[$i] == $attr)
{
$idx = $i;
break ;
}
}
// If we couldn't find it, it's not a ud, so ignore, we can't shift.
if ($idx < 0)
{
warning -sl 0 ("Can't shift "+$obj+"."+$attr+" it's not user defined.") ;
return ;
}
print ("// Shifting "+($dir==0 ? "Up" : "Down")+" "+$idx+".) "+$obj+"."+$attr+" //\n") ;
// Now shift as needed
if ($dir == 0 && $idx > 0)
{
cAE_dropToBottom($obj, $udAttrs[$idx]) ; // First this goes down
cAE_dropToBottom($obj, $udAttrs[$idx-1]) ; // Then the one above
// Then do the rest
for ($i=$idx+1; $i < size($udAttrs); ++$i)
{
cAE_dropToBottom($obj, $udAttrs[$i]) ;
}
}
else if ($dir == 1 && $idx < size($udAttrs)-1)
{
cAE_dropToBottom($obj, $udAttrs[$idx+1]) ; // First the one below goes down
cAE_dropToBottom($obj, $udAttrs[$idx]) ; // First this goes down
// Then do the rest
for ($i=$idx+2; $i < size($udAttrs); ++$i)
{
cAE_dropToBottom($obj, $udAttrs[$i]) ;
}
}
}
// --------------------------------------------------------------------------
/*
* cAE_dropToBottom() - Drop an attr to bottom by rename and back
*/
global proc cAE_dropToBottom(string $obj, string $attr)
{
renameAttr ($obj+"."+$attr) ($attr+"TEMPREN") ; // there
renameAttr ($obj+"."+$attr+"TEMPREN") ($attr) ; // and back again
}
// --------------------------------------------------------------------------