float $CBVal = `getAttr ($operation[1] + ".fraction")`;
floatSliderGrp -label "Corner Bevel " -field true -adjustableColumn 3
-minValue 0 -maxValue 1 -value $CBVal -precision 3 -cc ("updateValues(\""+$operation[1]+"\", \"floatCtrl1\")") floatCtrl1;
popupMenu -parent floatCtrl1 cornerResetPopup;
menuItem -label "Reset" -command "floatSliderGrp -edit -value ($CBVal) floatCtrl1;";
for some reason when right click the menu item to reset. It says "$CBVal" is an undeclared variable. when i clearly declared it at the start of the code.
Replies
- Toggle HTML view
- Paste your code
- Disable HTML view
- Select code
- Format > Code
That's certainly not optimal. I'll dig further.Scope error?
If neither: Have you confirmed that you actually get a float value returned from getAttr?
Either way you should put the code for resetting the UI control (floatSliderGrp) in a separate function and then call that function (cc flag) instead of having everything in the same place. Try and do as few things as possible within one scope (function, for loop, whatever) - that is a good practice to do for most code-related things. If something is too complex - move it to a separate function. It's easier to maintain as well.