// =========================================================================== // 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. // =========================================================================== // // Description: // An option window used for exporting a proxy container. // // // Procedure Name: // setOptionVars // // Description: // Initialize the option values. // // Input Arguments: // Whether to set the options to default values. // // Return Value: // None. // proc setOptionVars(int $forceFactorySettings) { if ($forceFactorySettings || !`optionVar -exists containerProxyName`) { optionVar -stringValue containerProxyName "proxy"; } if ($forceFactorySettings || !`optionVar -exists containerProxyFromTemplate`) { // 0 = from selected container // 1 = from template // optionVar -intValue containerProxyFromTemplate 0; } if ($forceFactorySettings || !`optionVar -exists containerProxyExport`) { // 0 = do not export, keep proxy in scene // 1 = export as reference proxy // optionVar -intValue containerProxyExport 1; } if ($forceFactorySettings || !`optionVar -exists containerProxyType`) { optionVar -stringValue containerProxyType "dagContainer"; } } // // Procedure Name: // exportContainerProxySetup // // Description: // Update the state of the option box UI to reflect the option values. // // Input Arguments: // parent - Top level parent layout of the option box UI. // Required so that UI object names can be // successfully resolved. // // forceFactorySettings - Whether the option values should be set to // default values. // // Return Value: // None. // global proc exportContainerProxySetup(string $parent, int $forceFactorySettings) { // Retrieve the option settings // setOptionVars( $forceFactorySettings ); setParent $parent; string $proxyName = `optionVar -q containerProxyName`; textFieldGrp -e -text $proxyName proxyNameWidget; int $fromTemplate = `optionVar -q containerProxyFromTemplate`; radioButtonGrp -edit -sl ($fromTemplate+1) proxyFromTemplateWidget; int $export = `optionVar -q containerProxyExport`; int $sel = ($export == 1) ? 1 : 2; radioButtonGrp -edit -enable ($fromTemplate == 0) -sl $sel proxyExportWidget; string $type = `optionVar -q containerProxyType`; int $dagContainer = ($type == "dagContainer"); checkBoxGrp -edit -enable ($fromTemplate == 1) -value1 $dagContainer proxyTypeWidget; } // // Procedure Name: // exportContainerProxyCallback // // Description: // Update the option values with the current state of the option box UI. // // Input Arguments: // parent - Top level parent layout of the option box UI. Required so // that UI object names can be successfully resolved. // // doIt - Whether the command should execute. // // Return Value: // None. // global proc exportContainerProxyCallback(string $parent, int $doIt) { setParent $parent; optionVar -stringValue containerProxyName `textFieldGrp -q -text proxyNameWidget`; int $fromTemplate = `radioButtonGrp -q -sl proxyFromTemplateWidget`; optionVar -intValue containerProxyFromTemplate ($fromTemplate-1); int $export = `radioButtonGrp -q -sl proxyExportWidget`; optionVar -intValue containerProxyExport ($export == 1); int $dagContainer = `checkBoxGrp -q -value1 proxyTypeWidget`; string $type = ($dagContainer) ? "dagContainer" : "container"; optionVar -stringValue $type containerProxyType; if ($doIt) { performExportContainerProxy 0; addToRecentCommandQueue "performExportContainerProxy 0" "Export Asset Proxy"; } } // // Procedure Name: // exportContainerProxyOptions // // Description: // Construct the option box UI. Involves accessing the standard option // box and customizing the UI accordingly. // // Input Arguments: // None. // // Return Value: // None. // proc exportContainerProxyOptions() { // Name of the command for this option box. // string $commandName = "exportContainerProxy"; // 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("containerProxy"); // 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_performExportContainerProxy.kSettings")) -collapsable 0`; columnLayout; // name for the proxy // textFieldGrp -label (uiRes("m_performExportContainerProxy.kName")) proxyNameWidget; radioButtonGrp -numberOfRadioButtons 2 -columnWidth3 170 160 200 -label (uiRes("m_performExportContainerProxy.kCreateFrom")) -label1 (uiRes("m_performExportContainerProxy.kSelectedContainer")) -label2 (uiRes("m_performExportContainerProxy.kTemplate")) -on1 "radioButtonGrp -e -enable 1 proxyExportWidget; checkBoxGrp -e -enable 0 proxyTypeWidget" -on2 "radioButtonGrp -e -enable 0 proxyExportWidget; checkBoxGrp -e -enable 1 proxyTypeWidget" proxyFromTemplateWidget; checkBoxGrp -label "" -label1 (uiRes("m_performExportContainerProxy.kWithTransform")) proxyTypeWidget; radioButtonGrp -numberOfRadioButtons 2 -columnWidth3 170 160 200 -label (uiRes("m_performExportContainerProxy.kNewProxy")) -label1 (uiRes("m_performExportContainerProxy.kExport")) -label2 (uiRes("m_performExportContainerProxy.kLeaveInScene")) proxyExportWidget; 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_performExportContainerProxy.kExportContainerProxyOptions")); // Step 8: Customize the 'Help' menu item text. // ============================================ // setOptionBoxHelpTag( "ExportContainerProxy" ); // Step 9: Set the current values of the option box. // ================================================= // eval (($setup + " " + $parent + " " + 0)); // Step 10: Show the option box. // ============================= // showOptionBox(); } // // Procedure Name: // assembleCmd // // Description: // Construct the command that will apply the option box values. // // Input Arguments: // None. // proc string assembleCmd() { setOptionVars(false); string $cmd = "doExportContainerProxy 2 {"; string $proxyName = "proxy1"; int $fromTemplate = 0; int $export = 1; string $type = "dagContainer"; if (`optionVar -exists containerProxyName`) { $proxyName = `optionVar -q containerProxyName`; } if (`optionVar -exists containerProxyFromTemplate`) { $fromTemplate = `optionVar -q containerProxyFromTemplate`; } if (`optionVar -exists containerProxyName`) { $export = `optionVar -q containerProxyExport`; } if (`optionVar -exists containerProxyType`) { $type = `optionVar -q containerProxyType`; } $cmd += ("\""+$proxyName + "\", \"" + $fromTemplate + "\", \"" + $type + "\", \"" + $export + "\" } "); return $cmd; } // // Procedure Name: // performExportContainerProxy // // Description: // Perform the proxy export using the corresponding // option values. This procedure will also show the option box // window if necessary as well as construct the command string // that will invoke the command with the current // option box values. // // Input Arguments: // 0 - Execute the command. // 1 - Show the option box dialog. // 2 - Return the command. // global proc string performExportContainerProxy(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: exportContainerProxyOptions; break; // Return the command string. // case 2: // Get the command. // $cmd = `assembleCmd`; break; } return $cmd; }