@@ -212,14 +212,67 @@ global proc unityImport(){
212
212
}
213
213
}
214
214
215
+ // returns the intersection of two string arrays
216
+ proc string[] getIntersection(string $set1[], string $set2[]){
217
+ string $myIntersector = `stringArrayIntersector`;
218
+
219
+ stringArrayIntersector -edit -reset $myIntersector;
220
+ stringArrayIntersector -edit -intersect $set1 $myIntersector;
221
+ stringArrayIntersector -edit -intersect $set2 $myIntersector;
222
+
223
+ string $intersection[] = `stringArrayIntersector -query $myIntersector`;
224
+
225
+ // Delete the intersector
226
+ deleteUI $myIntersector;
227
+
228
+ return $intersection;
229
+ }
215
230
216
- proc unityExport(int $exportAnim){
217
- // get the global variables
218
- global string $UnityExportSets[];
231
+ proc exportSet(string $unitySet, int $exportAnim){
219
232
global string $UnityFbxFilePathAttr;
220
233
global string $UnityFbxFileNameAttr;
221
234
global string $UnityFbxAnimFilePathAttr;
222
235
global string $UnityFbxAnimFileNameAttr;
236
+
237
+ string $unitySetContents[] = `listConnections $unitySet`;
238
+
239
+ string $animatedObjectSet = "";
240
+ if($exportAnim){
241
+ string $animCurveSelect[] = `ls -typ animCurve`;
242
+ string $animatedTransforms[] = `listConnections -t transform $animCurveSelect`;
243
+
244
+ string $setAnimatedTransforms[] = getIntersection($animatedTransforms, $unitySetContents);
245
+
246
+ select -r $setAnimatedTransforms;
247
+ $animatedObjectSet = `sets`;
248
+ select -r -ne $animatedObjectSet;
249
+ }
250
+
251
+ $pathAttr = $UnityFbxFilePathAttr;
252
+ $nameAttr = $UnityFbxFileNameAttr;
253
+
254
+ if($exportAnim){
255
+ $pathAttr = $UnityFbxAnimFilePathAttr;
256
+ $nameAttr = $UnityFbxAnimFileNameAttr;
257
+ }
258
+
259
+ $unity_fbx_file_path = getAttribute($unitySet, $pathAttr);
260
+ $unity_fbx_file_name = getAttribute($unitySet, $nameAttr);
261
+
262
+ $strCmd = "";
263
+ if ($unity_fbx_file_path != "" && $unity_fbx_file_name != ""){
264
+ $strCmd = "file -force -options \"\" -typ \"FBX export\" -pr -es \"" + $unity_fbx_file_path + "/" + $unity_fbx_file_name + "\"";
265
+ eval $strCmd;
266
+ }
267
+
268
+ if(setExists($animatedObjectSet)){
269
+ delete $animatedObjectSet;
270
+ }
271
+ }
272
+
273
+ proc unityExport(int $exportAnim){
274
+ // get the global variables
275
+ global string $UnityExportSets[];
223
276
224
277
if(!loadUnityDependencies()){
225
278
return;
@@ -238,26 +291,19 @@ proc unityExport(int $exportAnim){
238
291
return;
239
292
}
240
293
241
- string $myIntersector = `stringArrayIntersector`;
242
-
243
294
$i = 0;
244
295
string $setsToExport[];
245
296
for($exportSet in $UnityExportSets){
246
297
if(!setExists($exportSet)){
247
298
continue;
248
299
}
249
300
250
- stringArrayIntersector -edit -reset $myIntersector;
251
- stringArrayIntersector -edit -intersect $origSelection $myIntersector;
252
-
301
+ // check if the selection intersects with this export set
253
302
string $exportSetContents[] = `listConnections $exportSet`;
254
-
255
- stringArrayIntersector -edit -intersect $exportSetContents $myIntersector;
256
-
257
- string $intersection[] = `stringArrayIntersector -query $myIntersector`;
303
+ string $intersection[] = getIntersection($origSelection, $exportSetContents);
258
304
259
305
if(size($intersection) > 0 ||
260
- stringArrayContains($exportSet, $origSelection)){
306
+ stringArrayContains($exportSet, $origSelection)){
261
307
262
308
$setsToExport[$i] = $exportSet;
263
309
$i++;
@@ -272,50 +318,9 @@ proc unityExport(int $exportAnim){
272
318
273
319
for($unitySet in $setsToExport){
274
320
print ("exporting set: " + $unitySet);
275
-
276
- string $unitySetContents[] = `listConnections $unitySet`;
277
-
278
- string $animatedObjectSet = "";
279
- if($exportAnim){
280
- string $animCurveSelect[] = `ls -typ animCurve`;
281
- string $animatedTransforms[] = `listConnections -t transform $animCurveSelect`;
282
-
283
- stringArrayIntersector -edit -reset $myIntersector;
284
- stringArrayIntersector -edit -intersect $animatedTransforms $myIntersector;
285
- stringArrayIntersector -edit -intersect $unitySetContents $myIntersector;
286
-
287
- string $setAnimatedTransforms[] = `stringArrayIntersector -query $myIntersector`;
288
-
289
- select -r $setAnimatedTransforms;
290
- $animatedObjectSet = `sets`;
291
- select -r -ne $animatedObjectSet;
292
- }
293
-
294
- $pathAttr = $UnityFbxFilePathAttr;
295
- $nameAttr = $UnityFbxFileNameAttr;
296
-
297
- if($exportAnim){
298
- $pathAttr = $UnityFbxAnimFilePathAttr;
299
- $nameAttr = $UnityFbxAnimFileNameAttr;
300
- }
301
-
302
- $unity_fbx_file_path = getAttribute($unitySet, $pathAttr);
303
- $unity_fbx_file_name = getAttribute($unitySet, $nameAttr);
304
-
305
- $strCmd = "";
306
- if ($unity_fbx_file_path != "" && $unity_fbx_file_name != ""){
307
- $strCmd = "file -force -options \"\" -typ \"FBX export\" -pr -es \"" + $unity_fbx_file_path + "/" + $unity_fbx_file_name + "\"";
308
- eval $strCmd;
309
- }
310
-
311
- if(setExists($animatedObjectSet)){
312
- delete $animatedObjectSet;
313
- }
321
+ exportSet($unitySet, $exportAnim);
314
322
}
315
323
316
- // Delete the intersector
317
- deleteUI $myIntersector;
318
-
319
324
select -cl;
320
325
if (size($origSelection) > 0){
321
326
select -add -ne $origSelection;
0 commit comments