-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAEBOBNodeTemplate.mel
323 lines (249 loc) · 10.7 KB
/
AEBOBNodeTemplate.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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
global int $currLayer = -1;
//=====================================================================================================================//
// Initialize
//
//=====================================================================================================================//
global proc AEInitializeBuild (string $nodeNameArr) {
// get node name
string $buffer[];
tokenize($nodeNameArr,".",$buffer);
string $nodeName = $buffer[0];
//------------------------------------------------------------------------------------------------------------------//
// Attribute controls and buttons //
//------------------------------------------------------------------------------------------------------------------//
//--------------------------------------------------------------------------------------------------------------//
// User instructions / description //
//--------------------------------------------------------------------------------------------------------------//
separator -style none;
text -l "To create a LEGO layout of your mesh, first initialize it";
separator -style none;
string $initCmd = "editorTemplate -dimControl " + $nodeName + " InitializeButton true; \
button -e -enable false InitializeButton; \
button -e -enable true ExportButton; \
editorTemplate -dimControl " + $nodeName + " ExportButton false; \
button -e -enable true StepButton; \
editorTemplate -dimControl " + $nodeName + " StepButton false; \
setAttr -type \"string\" " + $nodeName + ".stabilityStatus \"Initializing...\";";
button -label "Initialize" -enable true -c $initCmd InitializeButton;
}
global proc AEInitializeUpdate (string $nodeNameArr) {
// get node name
string $buffer[];
tokenize($nodeNameArr,".",$buffer);
string $nodeName = $buffer[0];
string $initCmd = "";
// dim/undim attribute fields based on nodeStage
string $stage = `getAttr ($nodeName + ".stabilityStatus")`;
if ($stage == "Uninitialized") {
editorTemplate -dimControl $nodeName InitializeButton false;
button -e -enable true InitializeButton;
string $initCmd = "editorTemplate -dimControl " + $nodeName + " InitializeButton true; \
button -e -enable false InitializeButton; \
button -e -enable true ExportButton; \
editorTemplate -dimControl " + $nodeName + " ExportButton false; \
button -e -enable true StepButton; \
editorTemplate -dimControl " + $nodeName + " StepButton false; \
setAttr -type \"string\" " + $nodeName + ".stabilityStatus \"Initializing...\";";
} else { // do nothing, node has already been initialized
editorTemplate -dimControl $nodeName InitializeButton true;
button -e -enable false InitializeButton;
$initCmd = "";
}
button -edit -c $initCmd InitializeButton;
}
//=====================================================================================================================//
// Export
//
//=====================================================================================================================//
global proc openFileDialog(string $nodeName) {
string $filename = fileDialog("-dm", "*.pdf", "-mode", 1);
if ($filename != "")
{
setAttr -type "string" ($nodeName + ".exportPath") $filename;
setAttr -type "string" ($nodeName + ".stabilityStatus") "Exporting...";
}
}
global proc AEExportBuild (string $nodeNameArr) {
// get node name
string $buffer[];
tokenize($nodeNameArr,".",$buffer);
string $nodeName = $buffer[0];
//------------------------------------------------------------------------------------------------------------------//
// Attribute controls and buttons //
//------------------------------------------------------------------------------------------------------------------//
//--------------------------------------------------------------------------------------------------------------//
// User instructions / description //
//--------------------------------------------------------------------------------------------------------------//
separator -style none;
text -l "Export LEGO layout as a PDF";
separator -style none;
string $exportCmd = "openFileDialog(\"" + $nodeName + "\");";
button -label "Export Layout" -enable false -c $exportCmd ExportButton;
}
global proc AEExportUpdate (string $nodeNameArr) {
// do nothing, same process
}
//=====================================================================================================================//
// Step Button
//
//=====================================================================================================================//
global proc hideLayoutChildren() {
global int $currLayer;
if(objExists("legoLayout")) {
// hide children separately so they show up correctly
string $children[] = listRelatives("-children","legoLayout");
for($child in $children) {
hide($child);
}
$currLayer = 0;
}
}
global proc updateCurrLayerLabel(string $nodeName) {
global int $currLayer;
int $maxLayer = getAttr($nodeName + ".maxLayer") - 1;
string $label = "Current Layer: " + string($currLayer) + " / " + $maxLayer;
text -edit -l $label currLayerStr;
}
global proc step(string $nodeName) {
if(objExists("legoLayout")) {
global int $currLayer;
// reset if we hit max
int $maxLayer = getAttr($nodeName + ".maxLayer");
if($currLayer == $maxLayer - 1) {
print("currlayer == max \n");
$currLayer = -1;
//reset($nodeName);
}
if($currLayer == -1) {
hideLayoutChildren();
}
string $layerStr = "legoLayout|layer";
if ($currLayer < 10) {
$layerStr += "0";
}
$layerStr += string($currLayer);
if(objExists($layerStr)) {
showHidden($layerStr);
}
print("currLayer " + string($currLayer) + "\n");
updateCurrLayerLabel($nodeName);
$currLayer = $currLayer + 1;
}
}
global proc showFullLayout() {
global int $currLayer;
$currLayer = -1;
showHidden("legoLayout", "-b");
if(objExists("legoLayout")) {
string $children[] = listRelatives("-children","legoLayout");
for($child in $children) {
// showHidden($child);
}
}
}
global proc AEStepBuild (string $nodeNameArr) {
// get node name
string $buffer[];
tokenize($nodeNameArr,".",$buffer);
string $nodeName = $buffer[0];
//--------------------------------------------------------------------------------------------------------------//
// User instructions / description //
//--------------------------------------------------------------------------------------------------------------//
separator -style none;
text -l "Step through the layout";
separator -style none;
separator -style none;
text -l "Current Layer: " -fn "boldLabelFont" -align "left" currLayerStr;
separator -style none;
string $stepCmd = "step(\"" + $nodeName + "\");";
string $resetCmd = "reset();";
string $showFullCmd = "showFullLayout();";
//button - label "Reset" -enable false -c $resetCmd ResetStepButton;
button -label "Step" -enable false -c $stepCmd StepButton;
}
global proc AEStepUpdate (string $nodeNameArr) {
// do nothing, same process
}
//=====================================================================================================================//
// Constraint Dropdown
//=====================================================================================================================//
global proc string switchColorVal(string $nodeName) {
string $curr = `getAttr ($nodeName + ".colorConstraint")`;
if($curr == "HARD") {
return "SOFT";
} else {
return "HARD";
}
}
global proc AEColorConstraintBuild (string $nodeNameArr) {
// get node name
string $buffer[];
tokenize($nodeNameArr,".",$buffer);
string $nodeName = $buffer[0];
//-----------------------------------------------------------------------------------------------------------------//
// Attribute controls and buttons
//
//-----------------------------------------------------------------------------------------------------------------//
string $onChange = "setAttr -type \"string\" " + $nodeName + ".colorConstraint " + switchColorVal($nodeName);
optionMenuGrp -label "Color Constraint" -cc $onChange colorMenu;
menuItem -label "SOFT";
menuItem -label "HARD";
}
global proc AEColorConstraintUpdate (string $nodeNameArr) {
// get node name
string $buffer[];
tokenize($nodeNameArr,".",$buffer);
string $nodeName = $buffer[0];
//-----------------------------------------------------------------------------------------------------------------//
// Attribute controls and buttons
//
//-----------------------------------------------------------------------------------------------------------------//
string $stage = `getAttr ($nodeName + ".colorConstraint")`;
if ($stage == "HARD") {
optionMenuGrp -e -value "HARD" colorMenu;
} else {
optionMenuGrp -e -value "SOFT" colorMenu;
}
}
global proc AEBOBNodeTemplate( string $nodeName ) {
editorTemplate -beginLayout "BOBNode" -collapse false;
editorTemplate -suppress "caching";
editorTemplate -suppress "frozen";
editorTemplate -suppress "nodeState";
editorTemplate -suppress "colorConstraint";
editorTemplate -suppress "exportPath";
editorTemplate -suppress "jpgPath";
editorTemplate -suppress "maxLayer";
editorTemplate -suppress "outputMesh";
editorTemplate -suppress "inputMesh";
editorTemplate -suppress "oneXone";
editorTemplate -suppress "oneXtwo";
editorTemplate -suppress "oneXthree";
editorTemplate -suppress "oneXfour";
editorTemplate -suppress "oneXsix";
editorTemplate -suppress "oneXeight";
editorTemplate -suppress "twoXtwo";
editorTemplate -suppress "twoXthree";
editorTemplate -suppress "twoXfour";
editorTemplate -suppress "twoXsix";
editorTemplate -suppress "twoXeight";
editorTemplate -addControl "inputMeshName";
editorTemplate -addControl "meshTexture";
editorTemplate -addControl "stabilityStatus";
editorTemplate -addSeparator;
editorTemplate -beginLayout "Initialization" -collapse false;
editorTemplate -callCustom "AEInitializeBuild" "AEInitializeUpdate" $nodeName;
editorTemplate -endLayout;
editorTemplate -addSeparator;
editorTemplate -beginLayout "Layout Settings" -collapse false;
editorTemplate -addControl "useMeshColors";
editorTemplate -callCustom "AEColorConstraintBuild" "AEColorConstraintUpdate" $nodeName;
editorTemplate -endLayout;
editorTemplate -addSeparator;
editorTemplate -beginLayout "Layer Traversal" -collapse false;
editorTemplate -callCustom "AEStepBuild" "AEStepUpdate" $nodeName;
editorTemplate -endLayout;
editorTemplate -addSeparator;
editorTemplate -callCustom "AEExportBuild" "AEExportUpdate" $nodeName;
editorTemplate -endLayout;
}