-
Notifications
You must be signed in to change notification settings - Fork 0
/
mr_animLayer_snippets.mel
202 lines (147 loc) · 7.46 KB
/
mr_animLayer_snippets.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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
// ------------------------------------------------------------------------------------------------------------------------------------------------
// SCRIPT: animLayerTools
// VERSION: 0001
//
// CREATORS: Maria Robertson
// CREDIT: Eric Pavey
// -------------------------------------------------------------------
//
// DESCRIPTION:
// A bunch of mini-scripts to help work with animation layers faster.
// Took a while to research which commands to use, so gathered them here.
//
// This was made while learning MEL, so lots of commenting below.
//
// -------------------------------------------------------------------
//
// RESEARCH THAT HELPED:
// A great website by Eric Pavey for MEL info. Under the AnimLayer tag, there are
// lots of snippets on anim layers: http://mayamel.tiddlyspot.com
//
// ------------------------------------------------------------------------------------------------------------------------------------------------
// -------------------------------------------------------------------
// 00. SHOW ONLY ANIM CURVES OF BASE ANIMATION
// -------------------------------------------------------------------
global proc AnimLayer_ShowOnlyBaseAnimation() {
// By default in the Graph Editor, selecting an object will display its curves on all
// existing anim layers, even if locked or hidden.
// This script can help focus on BaseAnimation, avoiding the clutter.
// unhighlight all existing animation layers
setSelectedForAllLayers(0) ;
// highlight BaseAnimation
animLayerEditorOnSelect "BaseAnimation" 1 ;
}
// ------------------------------------------------------------------------------------------------------------------------------------------------
// -------------------------------------------------------------------
// 00. SHOW ONLY ANIM CURVES OF HIGHLIGHTED ANIM LAYERS
// -------------------------------------------------------------------
global proc AnimLayer_ShowOnlyHighlightedAnimLayerCurves() {
// Display only anim curves of highlighted animation layers for selected objects.
// create array of highlighted anim layers
string $highlightedAnimLayers[] = getSelectedAnimLayer("AnimLayerTab");
// for every highlighted anim layer
for ($item in $highlightedAnimLayers){
// rehighlight it (to refresh the Graph Editor)
// NOTE - 1 means highlight the layer, 0 means deselect it.
animLayerEditorOnSelect($item, 1) ;
}
}
// ------------------------------------------------------------------------------------------------------------------------------------------------
// -------------------------------------------------------------------
// 00. SELECT OBJECTS ON HIGHLIGHTED ANIM LAYERS
// -------------------------------------------------------------------
global proc AnimLayer_SelectHighlightedAnimLayerObjects_A() {
// create array of highlighted anim layers
string $highlightedAnimLayers[] = getSelectedAnimLayer("AnimLayerTab") ;
// select any objects on them
layerEditorSelectObjectAnimLayer($highlightedAnimLayers) ;
}
// ------------------------------------------------------------------------------------------------------------------------------------------------
// -------------------------------------------------------------------
// 00. SELECT HIGHLIGHTED ANIM LAYERS NODES
// -------------------------------------------------------------------
global proc AnimLayer_SelectAnimLayerNode() {
// create array of highlighted anim layers
string $highlightedAnimLayers[] = getSelectedAnimLayer("AnimLayerTab") ;
// reselect them
select $highlightedAnimLayers ;
}
// ------------------------------------------------------------------------------------------------------------------------------------------------
// -------------------------------------------------------------------
// 00. SELECT WEIGHT OF HIGHLIGHTED ANIM LAYERS
// -------------------------------------------------------------------
// Select the weights of selected animation layers
global proc AnimLayer_SelectWeightOfAnimLayers() {
// create array of highlighted anim layers
string $highlightedAnimLayers[] = getSelectedAnimLayer("AnimLayerTab") ;
// clear selection, to help refresh Graph Editor
select -cl ;
// for each anim layer
for ($item in $highlightedAnimLayers) {
if (`animLayer -q -selected $item`) {
// add to selection
select -add ($item + ".wgth") ;
}
}
}
// ------------------------------------------------------------------------------------------------------------------------------------------------
// -------------------------------------------------------------------
// 00. KEYFRAME WEIGHT OF HIGHLIGHTED ANIM LAYERS
// -------------------------------------------------------------------
global proc AnimLayer_KeyWeightNodes() {
// create array of highlighted anim layers
string $highlightedAnimLayers[] = getSelectedAnimLayer("AnimLayerTab");
// clear selection, to help refresh Graph Editor
select -cl ;
// key the weight nodes for selected animation layers
for ($item in $highlightedAnimLayers){
if (`animLayer -q -selected $item`){
setKeyframe ($item + ".wgth") ;
}
}
}
// ------------------------------------------------------------------------------------------------------------------------------------------------
// -------------------------------------------------------------------
// 00. GROUP HIGHLIGHTED ANIM LAYERS
// -------------------------------------------------------------------
// Create parent group for selected Animation Layers
global proc AnimLayer_CreateParentGroup() {
// create array of highlighted anim layers
string $highlightedAnimLayers[] = getSelectedAnimLayer("AnimLayerTab") ;
// create anim layer called Group
animLayer Group ;
// for each highlighted anim layer
for ($item in $highlightedAnimLayers){
// parent them under Group
animLayer -edit -parent Group $item ;
}
}
// ------------------------------------------------------------------------------------------------------------------------------------------------
// -------------------------------------------------------------------
// 00. TOGGLE LOCK HIGHLIGHED ANIM LAYES
// -------------------------------------------------------------------
// Toggle locking selected animation layers
global proc AnimLayer_ToggleLock() {
// create array of highlighted anim layers
string $highlightedAnimLayers[] = getSelectedAnimLayer("AnimLayerTab") ;
// for every layer
for ($item in $highlightedAnimLayers){
// declare its lock attribute
string $LockedLayerAttribute = `getAttr ($item + ".lo")` ;
// toggle off if on
if ($LockedLayerAttribute == 1) {
animLayer -edit -lock 0 $item ;
}
// toggle on if off
else {
animLayer -edit -lock 1 $item ;
}
}
}
// ------------------------------------------------------------------------------------------------------------------------------------------------
// -------------------------------------------------------------------
// 00. FIND WHICH SCRIPT CONTAINS THE MAYA COMMAND SPECIFIED
// -------------------------------------------------------------------
// Find which script contains the Maya command specified.
// Helpful when trying to understand what it does.
whatIs layerEditorSelectObjectAnimLayer ;