// =========================================================================== // Copyright 2018 Autodesk, Inc. All rights reserved. // // Use of this software is subject to the terms of the Autodesk license // agreement provided at the time of installation or download, or which // otherwise accompanies this software in either electronic or hard copy form. // =========================================================================== global proc exportSelectedToMudboxCallback(string $parent, int $doIt) { } global proc exportSelectedToMudboxSetup(string $parent, int $forceFactorySettings) { } proc string assembleCmd() { return "doPerformExportSelectedToMudbox"; } proc exportSelectedToMudboxOptions() { // Name of the command for this option box. // string $commandName = "exportSelectedToMudbox"; // Build the option box actions. // string $callback = ($commandName + "Callback"); string $setup = ($commandName + "Setup"); // STEP 1: Get the option box. // ============================ // // The value returned is the name of the layout to be used as // the parent for the option box UI. // string $layout = getOptionBox(); setParent $layout; // STEP 2: Pass the command name to the option box. // ================================================= // // Any default option box behaviour based on the command name is set // up with this call. For example, updating the 'Help' menu item with // the name of the command. // setOptionBoxCommandName("exportToMudbox"); // STEP 3: Activate the default UI template. // ========================================== // // Activate the default UI template so that the layout of this // option box is consistent with the layout of the rest of the // application. // setUITemplate -pushTemplate DefaultTemplate; // STEP 4: Create option box contents. // =================================== // // This, of course, will vary from option box to option box. // Turn on the wait cursor. // waitCursor -state 1; tabLayout -tabsVisible 0 -scrollable 1; string $parent = `columnLayout -adjustableColumn 1`; $layout = `frameLayout -label (uiRes("m_performExportSelectedToMudbox.kSettings")) -collapsable 0`; columnLayout; text -label (uiRes("m_performExportSelectedToMudbox.kPlaceholder")); setParent ..; setParent ..; // Turn off the wait cursor. // waitCursor -state 0; // Step 5: Deactivate the default UI template. // =========================================== // setUITemplate -popTemplate; // Step 6: Customize the buttons. // ============================== // // Provide more descriptive labels for the buttons. This is not // necessary, but in some cases, for example, a button labelled // 'Create' may be more meaningful to the user than one labelled // 'Apply'. // // Disable those buttons that are not applicable to the option box. // // Attach actions to those buttons that are applicable to the option // box. Note that the 'Close' button has a default action attached // to it that will hide the window. If a a custom action is // attached to the 'Close' button then be sure to call the 'hide the // option box' procedure within the custom action so that the option // box is hidden properly. // 'Apply' button. // string $applyBtn = getOptionBoxApplyBtn(); button -edit -command ($callback + " " + $parent + " " + 1) $applyBtn; // 'Save' button. // string $saveBtn = getOptionBoxSaveBtn(); button -edit -command ($callback + " " + $parent + " " + 0 + "; hideOptionBox") $saveBtn; // 'Reset' button. // string $resetBtn = getOptionBoxResetBtn(); button -edit -command ($setup + " " + $parent + " " + 1) $resetBtn; // Step 7: Set the option box title. // ================================= // setOptionBoxTitle (uiRes("m_performExportSelectedToMudbox.kExportSelectedToMudboxOptions")); // Step 8: Customize the 'Help' menu item text. // ============================================ // setOptionBoxHelpTag( "ExportSelectedToMudbox" ); // Step 9: Set the current values of the option box. // ================================================= // eval (($setup + " " + $parent + " " + 0)); // Step 10: Show the option box. // ============================= // showOptionBox(); } global proc doPerformExportSelectedToMudbox() { string $exe = ""; if (`optionVar -exists MUDBOX_LOCATION`) { $exe = `optionVar -q MUDBOX_LOCATION`; } if ($exe == "") { string $error = (uiRes("m_performExportSelectedToMudbox.kPathNotSet")); $error += (uiRes("m_performExportSelectedToMudbox.kSetPath")); error $error; } else if (!`filetest -x $exe`) { string $error = (uiRes("m_performExportSelectedToMudbox.kBadEXE")); $error += (uiRes("m_performExportSelectedToMudbox.kBadEXE2")); $error += $exe; $error += ("\""); error $error; } else if (!`pluginInfo -q -loaded fbxmaya`) { string $error = (uiRes("m_performExportSelectedToMudbox.kNoFBX")); error $error; } string $exportFolder = ""; if (`optionVar -exists MUDBOX_EXPORT_LOCATION`) { $exportFolder = `optionVar -q MUDBOX_EXPORT_LOCATION`; } if ($exportFolder == "") { string $error = (uiRes("m_performExportSelectedToMudbox.kExportFolderNotSet")); $error += (uiRes("m_performExportSelectedToMudbox.kSetExportFolder")); error $error; } else if (!`filetest -d $exportFolder`) { string $error = (uiRes("m_performExportSelectedToMudbox.kBadExportFolder")); $error += (uiRes("m_performExportSelectedToMudbox.kBadExportFolder2")); $error += $exportFolder; $error += ("\""); error $error; } string $fullPath; int $i; for ($i=1; $i<10000; $i++) { string $file = ($exportFolder + "/maya2mudbox_" + $i + ".fbx"); if (!`filetest -e $file`) { $fullPath = $file; break; } } if ("" != $fullPath) { // change to select tool to remove any selected manips, before export selected global string $gSelect; setToolTo $gSelect; string $result = `FBXExport -s -f $fullPath`; if ($result == "Success") { string $cmd = ("\"" + $exe + "\" -import "); $cmd += $fullPath; if (`about -nt`) { system("start " + $cmd); } else { system ($cmd +" >/dev/null 2>&1 &"); } } else { string $error = (uiRes("m_performExportSelectedToMudbox.kFBXresult")); $error += $result; error $error; } } else { string $error = (uiRes("m_performExportSelectedToMudbox.kNoFile")); error $error; } return; } global proc string performExportSelectedToMudbox(int $action) { string $cmd = ""; switch ($action) { // Execute the command. // case 0: // Get the command. // $cmd = `assembleCmd`; // Execute the command with the option settings. // evalEcho($cmd); break; // Show the option box. // case 1: exportSelectedToMudboxOptions; break; // Return the command string. // case 2: // Get the command. // $cmd = `assembleCmd`; break; } return $cmd; }