What is wrong with this script? (Toggle SliderBar color)

Im checking if the timeSliderBar is gray, if it is, do script A and turn it blue...but if its blue, then do script B and color it gray:

if (colorMan.getColor #timeSliderBg == [0.2, 0.2, 0.2])then
(
actionMan.executeAction 1937596344 "8" -- dRaster: Maya Style Navigation (Toggle)
macros.run "Tools" "SmartScale"
macros.run "DaveTools" "DaveTools_SubObjectModeToggle"

colorMan.setColor #timeSliderBg[0.0, 0.0, 0.6]
colorMan.repaintUI #repaintTimeBar
)
else if (colorMan.getColor #timeSliderBg == [0.0, 0.0, 0.6])then
(
actionMan.executeAction 1937596344 "8" -- dRaster: Maya Style Navigation (Toggle)
macros.run "Tools" "SmartScale"
macros.run "DaveTools" "DaveTools_SubObjectModeToggle"

colorMan.setColor #timeSliderBg[0.2, 0.2, 0.2]
colorMan.repaintUI #repaintTimeBar
)

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
miauu's picture

Try this: -- if the color is

Try this:

--	if the color is not blue or gray
if (colorMan.getColor #timeSliderBg != [0.2, 0.2, 0.2]) and (colorMan.getColor #timeSliderBg != [0.0, 0.0, 0.6]) then
(
	--	set it to blue or...
		actionMan.executeAction 1937596344 "8"
		macros.run "Tools" "SmartScale"
		macros.run "DaveTools" "DaveTools_SubObjectModeToggle"
 
		colorMan.setColor #timeSliderBg[0.0, 0.0, 0.6]	--	set it to blue
		colorMan.repaintUI #repaintTimeBar
	--	set it to gray
-- 		actionMan.executeAction 1937596344 "8"
-- 		macros.run "Tools" "SmartScale"
-- 		macros.run "DaveTools" "DaveTools_SubObjectModeToggle"
 
-- 		colorMan.setColor #timeSliderBg[0.2, 0.2, 0.2]	--	set it to gray
-- 		colorMan.repaintUI #repaintTimeBar
 
--	Next time when you run the script the color will be blue or gray and the code below will work as you wish.
)
else	--	else if the color is blue or gray
(
	if (colorMan.getColor #timeSliderBg == [0.2, 0.2, 0.2])then	--	if the color is gray
	(
		actionMan.executeAction 1937596344 "8"
		macros.run "Tools" "SmartScale"
		macros.run "DaveTools" "DaveTools_SubObjectModeToggle"
 
		colorMan.setColor #timeSliderBg[0.0, 0.0, 0.6]	--	set it to blue
		colorMan.repaintUI #repaintTimeBar
	)
	else
	(
		if (colorMan.getColor #timeSliderBg == [0.0, 0.0, 0.6])then	--	if the color is blue
		(
			actionMan.executeAction 1937596344 "8"
			macros.run "Tools" "SmartScale"
			macros.run "DaveTools" "DaveTools_SubObjectModeToggle"
 
			colorMan.setColor #timeSliderBg[0.2, 0.2, 0.2]	--	set it to gray
			colorMan.repaintUI #repaintTimeBar
		)
	)
)
general_knox's picture

Now I get it!!

Thanks, I see what I did wrong...this will help me a lot to do my own scripts now!

Back to reading the manual :)

miauu's picture

I use dark color scheme for

I use dark color scheme for max2009.
When I execute this line:
(colorMan.getColor #timeSliderBg == [0.2, 0.2, 0.2])
the returned result is FALSE
Then the script should go to this line:
if (colorMan.getColor #timeSliderBg == [0.0, 0.0, 0.6])then
but the returned result again is FALSE.
So there is nothing to execute, change or whatever.
:)

general_knox's picture

So how would one do it?

Im not too familiar yet with maxscript's way of doing else/if's...Im reading the manual though!

If someone would be kind enough to show an example of how this could work, Im sure I can get a lot of info out of it!

Thnx,

David

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.