-
Notifications
You must be signed in to change notification settings - Fork 0
/
Batch_FBX_Exporter.mel
88 lines (79 loc) · 2.55 KB
/
Batch_FBX_Exporter.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
global string $exportpath;
proc exportmesh(){
string $FinalExport;
string $selection[] = `ls -selection -long`;
print $selection[0]; //the first selected object
global string $exportpath;
string $path = `textField -q -fi sourcePath`;//grab the textField text
string $extension = ".fbx";
string $object;
// loop through all objects
for ( $object in $selection ) {
string $tokTmp[];
int $count = `tokenize $object "|" $tokTmp`;
string $result = $tokTmp[$count - 1];
print $object;
string $FinalExportPath = $exportpath + $object;
print $FinalExportPath;
select($object);
$FinalExport = $path + "/"+ $result + $extension;
FBXExport -f $FinalExport -s;
}
SelectPrevSelection($selection);
}
//creates ui
proc createui(){
global string $exportpath;
string $window = `window -title "FBX Batch Export"
-iconName "Short Name"
-widthHeight 260 200`;
columnLayout -columnAttach "both" 5 -rowSpacing 10 - columnWidth 250;
button -label "FreezeTransform" -h 20 -ann "FreezeTransform" -c "FreezeTransform()";
button -label "ResetPivot" -h 20 -ann "ResetPivot" -c "ResetPivot()";
button -label "Delete History" -h 20 -ann "Delete History" -c "DelHistory()";
text -label "Source Directory:" -align "left";
textField -w 250 -fi "" sourcePath;
button -label "Set default output path" -h 20 -ann "Browse for source folder..." -c "fileBrowserDialog -m 4 -fc \"onOk\" -ft \"directory\" -an \"Select Source Folder\"";
//button -label "SetExportLocation" -command "getFileSystem()";
button -label "ExportFBX" -command "exportmesh()";
showWindow $window;
}
//saves out to string filename and textField
proc onOk(string $filename, string $fileType){
$filename = $filename + "/";
textField -e -fi $filename sourcePath;
}
proc FreezeTransform()
{
string $selection[] = `ls -selection -long`;
for ( $object in $selection ) {
select($object);
FreezeTransformations;
makeIdentity -apply true -t 1 -r 1 -s 1 -n 0 -pn 1;
}
SelectPrevSelection($selection);
}
proc DelHistory(){
string $selection[] = `ls -selection -long`;
for ( $object in $selection ) {
select($object);
DeleteHistory;
}
SelectPrevSelection($selection);
}
proc SelectPrevSelection(string $selection[]){
for ( $object in $selection ) {
select -add ($object);
}
}
proc ResetPivot(){
string $selection[] = `ls -selection -long`;
for ( $object in $selection ) {
select($object);
xform -ws -piv 0 0 0 $object;
FreezeTransformations;
ResetTransformations;
}
SelectPrevSelection($selection);
}
createui();