[Closed] activate deactivate using checkbox
yeah i know that but it shows the same no matter whether the button is disabled or not…and i made something like this but it still shows the same tooltip that i gave near the button…if i remove it then no tooltip…
on testrender open do
(
btn2.enabled = false
if (Vray) != undefined then
(
btn2.enabled = true
)
case btn2.tooltip of
(
1:(btn.enabled = true; btn.tooltip = "Vray detected")
2:(btn.enabled = false; btn.tooltip = "No Vray")
)
)
Just put it inside:
if (Vray) != undefined then
(
btn2.enabled = true
btn2.tooltip = "Vray detected"
)
else btn2.tooltip = "No Vray"
Also if you want to use case of expression, bear in mind that the syntax should be like this for this example:
case btn2.enabled of
(
true : btn2.tooltip = "Vray detected"
false : btn2.tooltip = "No Vray"
)
i already tried this but it didnt worked for me…thats why i posted…
case btn2.enabled of ( true : btn2.tooltip = "Vray detected" false : btn2.tooltip = "No Vray" )
this one is working fine…i tried “case” method before but not like this…mine was different and thats why it didnt work…thanks for the tip…
PiXeL_MoNKeY: agreed
Well, be careful when using variables, I guess it was the same problem as with the previous one, trying to get a value for btn2 and setting one for btn. Otherwise it works, I’ve put it to action for you to see; but take this rather as a food for thought and for reference than anything else, PiXeL_MoNKeY made his version (that I used parts of here) much easier to understand.
try destroyDialog test catch()
rollout test "renderer"
(
button btn1 "Vray" enabled:false
button btn2 "QuickSilver" enabled:false
button btn3 "nTracer" enabled:false
local rendArr, btnArr = #(btn1, btn2, btn3)
fn setButtons btnNm rendNm =
(
if rendNm != undefined then
(
btnNm.enabled = true
btnNm.tooltip = (btnNm.caption + " available")
)
else btnNm.tooltip = (btnNm.caption + " not available")
)
on test open do
(
rendArr = #(Vray, Quicksilver_Hardware_Renderer, ntracer_renderer_cuda)
for ctrlNr = 1 to btnArr.count do
setButtons btnArr[ctrlNr] rendArr[ctrlNr]
)
)
createDialog test
Your example will never work, as tooltip doesn’t return a numeric value. Your current case test is saying:
if btn2.tooltip == 1 do (btn.enabled = true; btn.tooltip = "Vray detected")
if btn2.tooltip == 2 do (btn.enabled = false; btn.tooltip = "No Vray")
Personally I would develop some functions at the beginning of your rollout for things that you are constantly typing. On the tooltip issue you need to do:
if btn.enabled == true then
(
btn.tooltip = "button set"
)
else
(
btn.tooltip = "button not set"
)
I would highly suggest going through the maxscript help how to and rollout examples, as most of what you are asking and missing is described in the help. I am glad to help people out, but any time you hit a problem you come here for an answer. You need to work on your problem solve techniques or you will never be successful writing scripts. You need to ask and answer questions like: “What do I want to do?”, “What are all the options to achieve what I want?”, “What is the best solution for my problem?” for each problem you encounter.
That all being said this is how I would do your script so far:
--Always try ti destroy the dialog before defining and creating a new one.
try (destroydialog test) catch()
rollout test "renderers"
(
--Button Definitions--
button btn1 "Vray"
button btn2 "QuickSilver"
button btn3 "ntracer"
--Function Definitions--
fn setBtn rendNm btnNm =
(
if rendNm != undefined then
(
btnNm.enabled = true
)
)
fn setToolTip btnNm =
(
if btnNm.enabled == true then
(
btnNm.tooltip = (btnNm.caption+" set")
)
else
(
btnNm.tooltip = (btnNm.caption+" not set")
)
)
--Event Defintions--
on test open do
(
btn1.enabled = false
btn2.enabled = false
btn3.enabled = false
setBtn (Vray) btn1
setToolTip btn1
setBtn (Quicksilver_Hardware_Renderer) btn2
setToolTip btn2
setBtn (ntracer_renderer_cuda) btn3
setToolTip btn3
)
)
createdialog test
-Eric
Thank you all for your valuable tips…:):):)
swordslayer…:bowdown::bowdown::bowdown: