Skip to content

Commit f52fac1

Browse files
committed
export multiple sets based on selection
go through all selected items on export and determine which set they belong to. Export these sets
1 parent 9a5d44b commit f52fac1

File tree

1 file changed

+38
-13
lines changed

1 file changed

+38
-13
lines changed

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

Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ global proc unityImport(){
215215

216216
global proc unityExport(){
217217
// get the global variables
218-
global string $UnityExportSet;
218+
global string $UnityExportSets[];
219219
global string $UnityFbxFilePathAttr;
220220
global string $UnityFbxFileNameAttr;
221221

@@ -227,24 +227,49 @@ global proc unityExport(){
227227
return;
228228
}
229229

230-
// select the export set for export, if it exists,
231-
// otherwise take what is currently selected
232230
$origSelection = `ls -sl`;
233-
if (setExists($UnityExportSet)){
234-
select -r -ne $UnityExportSet;
231+
if(size($origSelection) <= 0){
232+
// nothing selected
233+
return;
235234
}
236235

237-
$unity_fbx_file_path = getAttribute($UnityExportSet, $UnityFbxFilePathAttr);
238-
$unity_fbx_file_name = getAttribute($UnityExportSet, $UnityFbxFileNameAttr);
236+
// create temporary set containing selection
237+
string $selectedSet = `sets`;
238+
$selectedSetList = {$selectedSet};
239239

240-
$strCmd = "";
241-
if ($unity_fbx_file_path != "" && $unity_fbx_file_name != ""){
242-
$strCmd = "file -force -options \"\" -typ \"FBX export\" -pr -es \"" + $unity_fbx_file_path + "/" + $unity_fbx_file_name + "\"";
240+
$i = 0;
241+
string $setsToExport[];
242+
for($exportSet in $UnityExportSets){
243+
if(!setExists($exportSet)){
244+
continue;
245+
}
246+
247+
if(`sets -isIntersecting $exportSet $selectedSetList`){
248+
$setsToExport[$i] = $exportSet;
249+
$i++;
250+
}
243251
}
244-
else {
245-
$strCmd = "SendToUnitySelection";
252+
253+
// delete temporary selection set
254+
delete $selectedSet;
255+
256+
for($unitySet in $setsToExport){
257+
print ("exporting set: " + $unitySet);
258+
259+
select -r -ne $unitySet;
260+
261+
$unity_fbx_file_path = getAttribute($unitySet, $UnityFbxFilePathAttr);
262+
$unity_fbx_file_name = getAttribute($unitySet, $UnityFbxFileNameAttr);
263+
264+
$strCmd = "";
265+
if ($unity_fbx_file_path != "" && $unity_fbx_file_name != ""){
266+
$strCmd = "file -force -options \"\" -typ \"FBX export\" -pr -es \"" + $unity_fbx_file_path + "/" + $unity_fbx_file_name + "\"";
267+
}
268+
else {
269+
$strCmd = "SendToUnitySelection";
270+
}
271+
eval $strCmd;
246272
}
247-
eval $strCmd;
248273

249274
select -cl;
250275
if (size($origSelection) > 0){

0 commit comments

Comments
 (0)