Maxscript Windows Chime - Active Window issue?

I have this bound to a hotkey and when I run it 3 times windows makes a "no" sound on the third button press. But then it will run on the forth press?

I honestly have no idea what the issue is.

Any ideas? Any help would be very appreciated.

The script just jumps between the top modifier and either last edit poly mod or base modifier.

local BaseSwitchSOL
 
if classof (modpanel.getcurrentobject()) == Editable_Poly or classof (modpanel.getcurrentobject()) == Edit_Poly then
            (
                BaseSwitchSOL = subobjectlevel
                modPanel.setCurrentObject $.modifiers[1]
            )
            else
            (
                try
                (
                    modPanel.setCurrentObject $.editpoly
                    subobjectlevel = BaseSwitchSOL
                )
                catch
                (
                    modPanel.setCurrentObject $.baseObject
                    if BaseSwitchSOL != undefined then
                    (
                        subobjectlevel = BaseSwitchSOL
                    )
                    else
                    (
                        subobjectlevel = 0
                    )
                )
            )

Comments

Comment viewing options

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

Solved! Sorta...

Just figured out that the issue has something to do with my home setup. It works fine at work.

jeremiah_bigley's picture

hotkey issue?

Much cleaner man thank you! However I am still having the previous issue. It works as a button perfectly but the moment I set it to a hotkey... max doesn't like it pressed 3 times in a row. :/ It works as long as I do something in the viewport in between each time I hit the hotkey... so strange.

Here is where I am at on the final. Code does what I want it to now just max is being stupid.

macroScript Bigley_Modifier_BaseSwitch
	category:"Bigley"
	toolTip:""
(
	global BaseSwitchSOL
 
	undo "Modifier Base Switch" on
	(
		if selection.count == 1 do
		(
			max modify mode
 
			local BaseSwitchCurMod = modPanel.getCurrentObject()
 
			if classOf BaseSwitchCurMod == Editable_Poly or \
			classOf BaseSwitchCurMod == Edit_Poly or \
			superclassof (modPanel.getCurrentObject()) == geometryclass then
			(
				BaseSwitchSOL = subObjectLevel
				subobjectlevel = 0
				try (modPanel.setCurrentObject $.modifiers[1]) catch(print "No top modifier.")
				subobjectlevel = 0
			)
			else 
			(
				if isProperty $ #editpoly then
				(
					subobjectlevel = 0
					modPanel.setCurrentObject $.editpoly
					subObjectLevel = 
					(
						if BaseSwitchSOL != undefined then
						(
							BaseSwitchSOL
						)
						else (0)
					)
				)
				else
				(
					subobjectlevel = 0
					modPanel.setCurrentObject $.baseObject
					subObjectLevel = 
					(
						if BaseSwitchSOL != undefined then
						(
							BaseSwitchSOL
						)
						else (0)
					)
				)
			)
		)
	)
)
Anubis's picture

not sure is this...

but why not move BaseSwitchSOL out of IF scope?
as currently it may stay undefined inside ELSE.
Or even do something like...

local BaseSwitchSOL = subObjectLevel
local curObj = modPanel.getCurrentObject()
if classOf curObj == Editable_Poly or \
classOf curObj == Edit_Poly then (
	modPanel.setCurrentObject $.modifiers[1]
)
else if isProperty $ #editpoly then (
	modPanel.setCurrentObject $.editpoly
	subObjectLevel = BaseSwitchSOL
)
else (
	modPanel.setCurrentObject $.baseObject
	subObjectLevel = \
	if BaseSwitchSOL != undefined then
		BaseSwitchSOL else 0
)

my recent MAXScripts RSS (archive here)

Comment viewing options

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