3dsMAX (max drawingaids) command

maxCommand (max drawingaids) will toggle the snaps window, but what if the user has the window already open?
In that case, when he/she launches my script, the snaps window closes.
There doesn’t seem to be a way to read the status of a Max window so that one can branch according to it.
For example
–always true, no matter if the window is open or closed
(max drawingaids) != active
–always false, no matter if the window is open or closed
(max drawingaids) == active

So conditional such as the one below never works, it does nothing but toggle the window, instead of opening (if closed) or refreshing (if already opened)
if (max drawingaids)!=active then (max drawingaids) else (max drawingaids; max drawingaids)

Has anybody come up with a workaround for this?

You could always check to see if there is a pop-up dialog of the appropriate title open and take action based on that - definitely not ideal, but then again, that’s par for the course in MXS.


fn OpenSnapWindow =
(
	local windowTitles = for windowHandle in (UIAccessor.GetPopupDialogs()) collect (UIAccessor.GetWindowText windowHandle)
	if ((findItem windowTitles "Grid and Snap Settings") == 0) then
	(
		max drawing aids
	)
)

That works like a charm, thanks!