Skip to content

Commit fec2348

Browse files
committed
find common namespace to display in create export dialog
1 parent 483fa7a commit fec2348

File tree

1 file changed

+25
-7
lines changed

1 file changed

+25
-7
lines changed

Integrations/Autodesk/maya/scripts/unityCommands.mel

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -783,6 +783,13 @@ proc string createTextFieldWithLabel(string $label, string $parent)
783783
}
784784

785785
proc createExportSetDialog(int $exportType){
786+
$origSelection = `ls -sl`;
787+
if(size($origSelection) <= 0){
788+
// nothing selected
789+
print ("Nothing selected");
790+
return;
791+
}
792+
786793
$exportAnim = false;
787794
$exportAnimOnly = false;
788795
switch($exportType){
@@ -803,9 +810,27 @@ proc createExportSetDialog(int $exportType){
803810
string $container = `formLayout -numberOfDivisions 100`;
804811

805812
string $mainOptions = `columnLayout -adjustableColumn true -p $container`;
813+
814+
// go through selection to find common namespace to set as default
815+
string $commonNamespace = ":";
816+
int $maxNamespaceCount = 0;
817+
for($i = 0; $i < size($origSelection); $i++){
818+
string $currNamespace = getObjectNamespace($origSelection[$i]);
819+
while ($currNamespace != ":"){
820+
// get contents of namespace
821+
string $namespaceContents[] = `namespaceInfo -ls $currNamespace`;
822+
string $intersection[] = getIntersection($origSelection, $namespaceContents);
823+
if(size($intersection) > $maxNamespaceCount){
824+
$commonNamespace = $currNamespace;
825+
$maxNamespaceCount = size($intersection);
826+
}
827+
$currNamespace = `namespaceInfo -p $currNamespace`;
828+
}
829+
}
806830

807831
// get namespace
808832
string $namespaceField = createTextFieldWithLabel("Unity FBX namespace", $mainOptions);
833+
textField -e -text $commonNamespace $namespaceField;
809834

810835
string $modelFilePath = " 0 0";
811836
if(!$exportAnimOnly){
@@ -942,13 +967,6 @@ global proc unityExportModelAnim(){
942967
}
943968

944969
global proc unityCreateExportSet(){
945-
$origSelection = `ls -sl`;
946-
if(size($origSelection) <= 0){
947-
// nothing selected
948-
print ("Nothing selected");
949-
return;
950-
}
951-
952970
global int $UnityExportModelAnim;
953971
createExportSetDialog($UnityExportModelAnim);
954972
}

0 commit comments

Comments
 (0)