ScriptSpot

Forum topic · General Scripting

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

By general_knox · 2011-09-14

Description

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 (4)

Try this: -- if the color is

miauu · 2011-09-15

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
		)
	)
)

Now I get it!!

general_knox · 2011-09-16

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 · 2011-09-14

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.
:)

So how would one do it?

general_knox · 2011-09-15

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