// =========================================================================== // 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 assemblyDefinitionAddLocator`) { optionVar -intValue assemblyDefinitionAddLocator 1; } } // Update the state of the option box UI to reflect the option values. global proc assemblyDefinitionOptionsSetup(string $parent, int $forceFactorySettings) { // Retrieve the option settings setOptionVars($forceFactorySettings); setParent $parent; // Query the optionVar's and set the values into the controls. checkBox -edit -value `optionVar -query assemblyDefinitionAddLocator` checkBoxAddLocatorRep; } // Update the option values with the current state of the option box UI. global proc assemblyDefinitionOptionsCallback(string $parent, int $doIt) { setParent $parent; optionVar -intValue assemblyDefinitionAddLocator `checkBox -query -value checkBoxAddLocatorRep`; if($doIt){ assemblyCreate assemblyDefinition; } } // Construct the assembly definition option box UI. global proc assemblyDefinitionOptionBox() { // Name of the command for this option box. string $commandName = "assemblyDefinitionOptions"; // 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`; frameLayout -label (uiRes("m_assemblyDefinitionOptionBox.kAssemblyRepresentationsLayout")) -collapse false; columnLayout -adjustableColumn 1; rowLayout -numberOfColumns 1 -columnAttach 1 "left" 80; checkBox -label (uiRes("m_assemblyDefinitionOptionBox.kAddLocatorRepresentation")) checkBoxAddLocatorRep; setParent ..; setParent ..; setParent ..; // Turn off the wait cursor. waitCursor -state 0; // Step 5: Deactivate the default UI template. // =========================================== // setUITemplate -popTemplate; // Step 6: Customize the buttons. // ============================== // // 'Create' button. string $create = getOptionBoxApplyAndCloseBtn(); // Hide the option box before we create the assembly definition or else it seems that the window is freezed for few sec. button -edit -label (uiRes("m_assemblyDefinitionOptionBox.kAssemblyDefinitionOptionsCreate")) -command ("hideOptionBox;"+ $callback + " " + $parent + " " + 1) $create; // 'Save And Close' button. string $saveCloseBtn = getOptionBoxApplyBtn(); button -edit -label (uiRes("m_assemblyDefinitionOptionBox.kAssemblyDefinitionOptionsSaveClose")) -command ($callback + " " + $parent + " " + 0 + "; hideOptionBox") $saveCloseBtn; // 'Cancel' button. string $closeBtn = getOptionBoxCloseBtn(); button -edit -label (uiRes("m_assemblyDefinitionOptionBox.kAssemblyDefinitionOptionsCancel")) $closeBtn; // '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_assemblyDefinitionOptionBox.kAssemblyDefinitionOptionsTitle")); // Step 8: Customize the 'Help' menu item text. // ============================================ // setOptionBoxHelpTag( "AssemblyDefinitionOptions" ); // Step 9: Set the current values of the option box. // ================================================= // eval(($setup + " " + $parent + " " + 0)); // Step 10: Show the option box. // ============================= // showOptionBox(); }