Skip to content

Commit df73419

Browse files
committed
use string intersection instead of set intersections
also when selection animated nodes, make sure to intersect with the current set first so that we don't export all animated nodes in the scene.
1 parent 3ea3768 commit df73419

File tree

1 file changed

+23
-9
lines changed

1 file changed

+23
-9
lines changed

Assets/Integrations/Autodesk/maya/scripts/unityCommands.mel

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -238,9 +238,7 @@ proc unityExport(int $exportAnim){
238238
return;
239239
}
240240

241-
// create temporary set containing selection
242-
string $selectedSet = `sets`;
243-
$selectedSetList = {$selectedSet};
241+
string $myIntersector = `stringArrayIntersector`;
244242

245243
$i = 0;
246244
string $setsToExport[];
@@ -249,17 +247,23 @@ proc unityExport(int $exportAnim){
249247
continue;
250248
}
251249

252-
if(`sets -isIntersecting $exportSet $selectedSetList` ||
250+
stringArrayIntersector -edit -reset $myIntersector;
251+
stringArrayIntersector -edit -intersect $origSelection $myIntersector;
252+
253+
string $exportSetContents[] = `listConnections $exportSet`;
254+
255+
stringArrayIntersector -edit -intersect $exportSetContents $myIntersector;
256+
257+
string $intersection[] = `stringArrayIntersector -query $myIntersector`;
258+
259+
if(size($intersection) > 0 ||
253260
stringArrayContains($exportSet, $origSelection)){
254261

255262
$setsToExport[$i] = $exportSet;
256263
$i++;
257264
}
258265
}
259266

260-
// delete temporary selection set
261-
delete $selectedSet;
262-
263267
// if selection doesn't belong to a set, export to a new file
264268
if(size($setsToExport) <= 0){
265269
eval "SendToUnitySelection";
@@ -269,12 +273,19 @@ proc unityExport(int $exportAnim){
269273
for($unitySet in $setsToExport){
270274
print ("exporting set: " + $unitySet);
271275

272-
select -r -ne $unitySet;
276+
string $unitySetContents[] = `listConnections $unitySet`;
273277

274278
if($exportAnim){
275279
string $animCurveSelect[] = `ls -typ animCurve`;
276280
string $animatedTransforms[] = `listConnections -t transform $animCurveSelect`;
277-
select -r $animatedTransforms;
281+
282+
stringArrayIntersector -edit -reset $myIntersector;
283+
stringArrayIntersector -edit -intersect $animatedTransforms $myIntersector;
284+
stringArrayIntersector -edit -intersect $unitySetContents $myIntersector;
285+
286+
string $setAnimatedTransforms[] = `stringArrayIntersector -query $myIntersector`;
287+
288+
select -r $setAnimatedTransforms;
278289
}
279290

280291
$pathAttr = $UnityFbxFilePathAttr;
@@ -295,6 +306,9 @@ proc unityExport(int $exportAnim){
295306
}
296307
}
297308

309+
// Delete the intersector
310+
deleteUI $myIntersector;
311+
298312
select -cl;
299313
if (size($origSelection) > 0){
300314
select -add -ne $origSelection;

0 commit comments

Comments
 (0)