summaryrefslogtreecommitdiffstats
path: root/tools/MayaTools/Maya4.0/scripts/SimpsonsArt/yuya_copyFileTex.mel
blob: 7c018f9904b52a1bc3b94a5b7ab6a2fd8e3ebe21 (plain) (blame)
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
//
// Copy File Textures Ver.1.51
//
// Created by Yuya Sugiyama < yuya@sb.sakura.ne.jp >
// Last Modify : 16th/December/2001
// Please check my web site -INVISIBLE-.
// URL : http://sb.sakura.ne.jp/~yuya/
//
// Description:
//  This script copies file textures in current scene to current sourceimages
//  directory. This script makes your file management easier.
//
// Usage:
//  Type
//
//	yuya_copyFileTex;
//
//  Then appear the window. Set options and hit "Copy File Textures" button.
//  Using specify directory option, path must be terminated in "\"(backslash).
//  (If you use browse button, unnecessary paying attention to this limitation.)
//
// Please use (and modify) this at your own lisk.
//


// Start window procedure

global proc yuya_copyFileTex () {

if ((`window -ex yuya_copyFileTex`) == true) deleteUI yuya_copyFileTex;
window -t "Copy File Texture" -w 420 -h 100  yuya_copyFileTex;
columnLayout -adj 1;

frameLayout -l "Copy File Texture" -la "center" -bs "etchedIn" -cll 1 -cl 0;

columnLayout -adj 1;
radioButtonGrp -w 330 -cw3 140 100 100 -nrb 2 -label "Which Files?" -la2 "All Files" "Selected Files" -select 1 yuya_allOrSel;

columnLayout -adj 1;
radioButtonGrp -w 330 -cw3 140 100 100 -nrb 2 -label "Mofify Texture Node?" -la2 "Yes" "No" -select 1 yuya_modTexNode;

checkBoxGrp -l "Specify Directory"
	-onCommand
		"textFieldGrp -e -ed true yuya_cftDirField;
		symbolButton -e -enable true yuya_cftBrowseButton;"
	-offCommand
		"textFieldGrp -e -ed false yuya_cftDirField;
		symbolButton -e -enable false yuya_cftBrowseButton;"
	yuya_cftCB;

rowLayout -w 330 -nc 2 -cw2 380 40 -cal 1 "right" yuya_cftDirNameLayout;
textFieldGrp -l "Directory" -ed false -w 375 yuya_cftDirField;
symbolButton
	-enable false
	-image "navButtonBrowse.xpm"
	 -c "yuya_getDirProc" yuya_cftBrowseButton;

setParent..;
setParent..;
setParent..;
setParent..;

button -l "Copy File Textures." -c "yuya_copyFileTexMain (`radioButtonGrp -q -select yuya_allOrSel`) (`radioButtonGrp -q -select yuya_modTexNode`)";

showWindow;

}

// End create window procedure


// Start copy file textures procedure

global proc int yuya_copyFileTexMain ( int $allOrSel, int $modTexNode ) {

if ( $allOrSel == 1 ) {
	select -all;
}

string $path[] = `ls -sl -type file`;
select -cl;

if ( $allOrSel == 2 ) {
	select -add $path;
}

string $copyPath;

if (`checkBoxGrp -q -value1 yuya_cftCB`){

	$copyPath = `textFieldGrp -q -fileName yuya_cftDirField`;

}else{
	$copyPath =`workspace -q -rd`+"sourceimages/";
	for ($i=1; $i<=17; $i++){
		$copyPath = `substitute "/" $copyPath "\\"`;
	}
}

string $batchName = `file -q -sceneName`;

if( `size($batchName)` ){
	string $tokBatName[];
	int $numTokenB = `tokenize $batchName "/" $tokBatName`;
	$batchName = $tokBatName[$numTokenB-1] +".bat";
	$batchName = `substitute ".ma" $batchName ""`;
	$batchName = `substitute ".mb" $batchName ""`;

}else{
	$batchName = "untitled.bat";
}

system ("echo on>"+$copyPath+"copyFileTex_"+$batchName);

string $current;
for ( $current in $path ) {

	string $currentFullPath = `getAttr ($current + ".ftn")`;

	string $tokFileName[];
	int $numToken = `tokenize $currentFullPath "/" $tokFileName`;
	string $fileName = $tokFileName[$numToken-1];

	for ($i=1; $i<=17; $i++){
		$currentFullPath = `substitute "/" $currentFullPath "\\"`;
	}

	system ("echo copy \""+$currentFullPath+"\" \""+$copyPath+"\">>\""+$copyPath+"copyFileTex_"+$batchName+"\"");


}

system ("echo del \""+$copyPath+"copyFileTex_"+$batchName+"\">>\""+$copyPath+"copyFileTex_"+$batchName+"\"");
system ("start \""+$copyPath+"copyFileTex_"+$batchName+"\"");

if ($modTexNode == 1){

	for ( $current in $path ) {

		string $currentFullPath = `getAttr ($current + ".ftn")`;

		string $tokFileName[];
		int $numToken = `tokenize $currentFullPath "/" $tokFileName`;
		string $fileName = $tokFileName[$numToken-1];

		setAttr ( $current + ".ftn" ) -type "string" ($copyPath+$fileName);

	}

}

return 1;

}

// End copy file textures procedure


// Get Directory Name

global proc yuya_getDirProc(){

fileBrowser "yuya_getDirNameProc" "Select Directory" "directory" 4;

}

global proc yuya_getDirNameProc(string $dir, string $type){

textFieldGrp -e -fileName ($dir+"\\") yuya_cftDirField;

}