// =========================================================================== // 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. // =========================================================================== // Default option settings proc setOptionVars(int $forceFactorySettings) { if ($forceFactorySettings || !`optionVar -exists assemblyLoadRepOnCreation`) { optionVar -intValue assemblyLoadRepOnCreation 1; } } global proc assemblyCreateRepresentationOptionBoxSetup(string $parent, int $forceFactorySettings) { // Retrieve the option settings setOptionVars($forceFactorySettings); setParent $parent; // remove the changeCommand assigned, since we want to manage saved optVar values. checkBoxGrp -edit -cc1 "" assemblyLoadRepOnCreationChk; checkBoxGrp -edit -value1 `optionVar -query assemblyLoadRepOnCreation` assemblyLoadRepOnCreationChk; } global proc assemblyCreateRepresentationOptionBoxCallback(string $parent) { setParent $parent; optionVar -intValue assemblyLoadRepOnCreation `checkBoxGrp -query -value1 assemblyLoadRepOnCreationChk`; } // Construct the option box UI. // Involves accessing the standard option box and customizing the UI accordingly. global proc assemblyCreateRepresentationOptionBox(string $createRepCmd) { // Name of the command for this option box. string $commandName = "assemblyCreateRepresentationOptionBox"; // Build the option box actions. string $callback = ($commandName + "Callback"); string $setup = ($commandName + "Setup"); // STEP 1: Get the option box. // ============================ // string $layout = getOptionBox(); setParent $layout; // STEP 2: Pass the command name to the option box. // ================================================= // setOptionBoxCommandName($commandName); // STEP 3: Activate the default UI template. // ========================================== // setUITemplate -pushTemplate DefaultTemplate; // STEP 4: Create option box contents. // =================================== // // Turn on the wait cursor. waitCursor -state 1; tabLayout -tabsVisible 0 -scrollable 1; string $parent = `columnLayout -adjustableColumn 1`; assemblyDefinitionCreateRepresentationUIOption($parent); // Turn off the wait cursor. waitCursor -state 0; // Step 5: Deactivate the default UI template. // =========================================== // setUITemplate -popTemplate; // Step 6: Customize the buttons. // ============================== // string $applyCloseBtn = getOptionBoxApplyAndCloseBtn(); button -edit -label (uiRes("m_assemblyCreateRepresentationOptionBox.kAddRepresentationOptions")) -command ($callback + " " + $parent + "; hideOptionBoxNow; " + $createRepCmd ) $applyCloseBtn; // 'Save and Close' button. string $applyBtn = getOptionBoxApplyBtn(); button -edit -label (uiRes("m_assemblyCreateRepresentationOptionBox.kSaveCloseRepresentationOptions")) -command ($callback + " " + $parent + "; hideOptionBox") $applyBtn; // 'Cancel' button. string $cancelBtn = getOptionBoxCloseBtn(); button -edit -label (uiRes("m_assemblyCreateRepresentationOptionBox.kCancelRepresentationOptions")) $cancelBtn; // 'Save' button. string $saveBtn = getOptionBoxSaveBtn(); button -edit -command ($callback + " " + $parent + "; hideOptionBox") $saveBtn; // 'Reset' button. string $resetBtn = getOptionBoxResetBtn(); button -edit -command ($setup + " " + $parent + " " + 1) $resetBtn; // Step 7: Set the option box title. // ================================= // setOptionBoxTitle (uiRes("m_assemblyCreateRepresentationOptionBox.kAssemblyDefinitonRepresentationTitle")); // Step 8: Customize the 'Help' menu item text. // ============================================ // setOptionBoxHelpTag( "" ); // Step 9: Set the current values of the option box. // ================================================= // eval(($setup + " " + $parent + " " + 0)); // Step 10: Show the option box. // ============================= // showOptionBox(); }