Notifications
Clear all

[Closed] do nothing with slider?

 smo

Hi again!

I just started scripting and am a complete noob!
Trying to make a slider inactive when the object isn’t selected.
Can’t for the love of god figure this out:/ Any masters out there:)

heres the script:

	    Rollout Menu01 "Stones"
(
	    button makechipped "Chipped Stone" pos:[2,6] width:80 height:20
	    button makesmooth "Smooth Stone" pos:[82,6] width:80 height:20
	    slider detaillevels "Iterations" range:[0,5,4] pos:[2,30] width:170 height:10
	    --script
	
        on detaillevels changed value do
(
		$.modifiers[#TurboSmooth].iterations = value
)


3 Replies

The solution is: callbacks!

It always watching what you are doing on the scene, and if the statement “if theSelection == undefined then” it turns off the spinner. (Enabled:false) else (enabled:true)

true.
callbacks mechanism is a solution:


 try(destroydialog selectionTest) catch()
 rollout selectionTest "Selection Test" width:200
 (
 	slider only_sel_alive width:180 align:#left offset:[4,0]
 	on selectionTest close do
 	(
 		callbacks.removescripts id:#select_monitor
 	)
 	on selectionTest open do
 	(
 		callbacks.removescripts id:#my_select_monitor
 		callbacks.addscript #selectionSetChanged \
 			"selectionTest.only_sel_alive.enabled = (selection.count > 0)" id:#my_select_monitor
 		only_sel_alive.enabled = (selection.count > 0)
 	)
 )
 createdialog selectionTest
 smo

I tried the solutions you gave but they didnt work as I wanted. So I played around with them a bit and ended up with this! whitch worked great:)

Thanks guys!

 Rollout Menu01 "Stones"
(
	    button makechipped "Chipped Stone" pos:[2,6] width:80 height:20
	    button makesmooth "Smooth Stone" pos:[82,6] width:80 height:20
	    slider detaillevels "Iterations" range:[0,5,4] pos:[2,30] width:170 height:10
	    --script
	
	    on detaillevels changed value do
		
(
	    if (selection.count > 0 and ($.name == "Chipped Stone" or $.name == "Smooth Stone")) then $.modifiers[#TurboSmooth].iterations = value
)