// Creation Date: Oct. 2004 CPAM // Author: ECLO Kashima // // Description: This script sets vertex value. // ----------------- // Comand "setValue 1" window open. // ////////////////////////////////////////////////////////////////////// //setOptionVars ////////////////////////////////////////////////////////////////////// proc setOptionVars (int $forceFactorySettings){ // Axis flag // if ($forceFactorySettings || !`optionVar -exists setValueAxis`) { optionVar -intValue setValueAxis 1; } if ($forceFactorySettings || !`optionVar -exists setValueTX`) { optionVar -floatValue setValueTX 0.0; } } ////////////////////////////////////////////////////////////////////// //setValueSetup ////////////////////////////////////////////////////////////////////// global proc setValueSetup (string $parent, int $forceFactorySettings){ setOptionVars ($forceFactorySettings); setParent $parent; // Axis flag // radioButtonGrp -edit -select `optionVar -q setValueAxis` setValueAxis; float $tx = `optionVar -q setValueTX`; floatFieldGrp -edit -value1 $tx setValueTranslate; setValueOptionsUpdateEnableState($parent); } ////////////////////////////////////////////////////////////////////// //setValueOptionsUpdateEnableState ////////////////////////////////////////////////////////////////////// global proc setValueOptionsUpdateEnableState(string $parent){ setParent $parent; } ////////////////////////////////////////////////////////////////////// //setValueCallback ////////////////////////////////////////////////////////////////////// global proc setValueCallback (string $parent, int $doIt){ setParent $parent; //axis // optionVar -intValue setValueAxis `radioButtonGrp -query -select setValueAxis`; optionVar -floatValue setValueTX `floatFieldGrp -q -v1 setValueTranslate`; // if ($doIt) { setValue 0; addToRecentCommandQueue "setValue 0" "Set Value"; // } } ////////////////////////////////////////////////////////////////////// //setValueOptions ////////////////////////////////////////////////////////////////////// proc setValueOptions (){ string $cmdName = "setValue"; string $callback = ($cmdName + "Callback"); string $setup = ($cmdName + "Setup"); // STEP 1: Get the option box. // ============================ string $layout = getOptionBox(); setParent $layout; // STEP 2: Pass the command name to the option box. // ================================================= setOptionBoxCommandName($cmdName); // STEP 3: Activate the default UI template. // ========================================== setUITemplate -pushTemplate DefaultTemplate; waitCursor -state 1; // STEP 4: Create option box contents. // =================================== tabLayout -scr true -tv false; string $parent = `columnLayout -adjustableColumn 1`; radioButtonGrp -label "Axis" -numberOfRadioButtons 3 -label1 "X" -label2 "Y" -label3 "Z" setValueAxis; floatFieldGrp -label "Set Value" -numberOfFields 1 setValueTranslate; waitCursor -state 0; // Step 5: Deactivate the default UI template. // =========================================== setUITemplate -popTemplate; // Step 6: Customize the buttons. // ============================== string $applyBtn = getOptionBoxApplyBtn(); button -edit -label "Set Value" -command ($callback + " " + $parent + " " + 1) $applyBtn; string $saveBtn = getOptionBoxSaveBtn(); button -edit -command ($callback + " " + $parent + " " + 0 + "; hideOptionBox") $saveBtn; string $resetBtn = getOptionBoxResetBtn(); button -edit -command ($setup + " " + $parent + " " + 1) $resetBtn; // Set the option box title. // ========================= setOptionBoxTitle("Set Value"); setOptionBoxHelpTag( "Set Value" ); eval (($setup + " " + $parent + " " + 0)); showOptionBox(); } ////////////////////////////////////////////////////////////////////// //assembleCmd ////////////////////////////////////////////////////////////////////// proc string assembleCmd(){ string $cmd = ""; setOptionVars(false); // Axis flag // int $axisFlag = `optionVar -query setValueAxis`; float $transX = `optionVar -q setValueTX`; if ($axisFlag == 1){ $cmd += "scale "; $cmd += "-r "; $cmd += "-p "; $cmd += ($transX + "cm "); $cmd += "0cm "; $cmd += "0cm "; $cmd += "0 1 1"; $cmd += ";"; } if ($axisFlag == 2){ $cmd += "scale "; $cmd += "-r "; $cmd += "-p "; $cmd += "0cm "; $cmd += ($transX + "cm "); $cmd += "0cm "; $cmd += "1 0 1"; $cmd += ";"; } if ($axisFlag == 3){ $cmd += "scale "; $cmd += "-r "; $cmd += "-p "; $cmd += "0cm "; $cmd += "0cm "; $cmd += ($transX + "cm "); $cmd += "1 1 0"; $cmd += ";"; } print "\n"; print $cmd; print "\n"; return $cmd; } ////////////////////////////////////////////////////////////////////// //setValue ////////////////////////////////////////////////////////////////////// global proc string setValue(int $action){ string $cmd = ""; switch ($action) { case 0: $cmd = `assembleCmd`; eval($cmd); break; case 1: setValueOptions(); break; case 2: $cmd = `assembleCmd`; break; } return $cmd; }