CGTalk > Software > Autodesk 3ds max > 3dsMax SDK and MaxScript
Login register
Thread Closed share thread « Previous Thread | Next Thread »  
 
Thread Tools Search this Thread Display Modes
Old 04-30-2013, 02:07 PM   #1
namoi
Veteran
 
Join Date: Oct 2004
Posts: 65
NitrousGraphicsManager

Hi,

I'm trying to create a toggle button to switch between realistic and the previous visual style the active viewport was on.

In theory it is very simple using NitrousGraphicsManager.GetActiveViewportSetting() and a #viewportChange callback used to get the current style of the active viewport.

Basically the toggle works like this:

If the active viewport is already in realistic mode, i want the toggle to automatically reflect this, and so be "on", and if the viewport has another style the toggle is "off" and clicking on it will switch to realistic, clicking again will revert to the previous style. Very simple.

And i succeeded... until i restarted max which throw me a bunch of errors.

The problem is that the macroscript for the button is evaluated BEFORE the viewports even exists : the variable which will handle the visual style is still undefined and so the toggle can't decide if it is on or off...

So my question is : how could i do to postpone the evaluation of the macroscript AFTER the first redraw of the viewport and so avoiding this error ?

Thanks

 
Old 04-30-2013, 03:10 PM   #2
lo
the frequentest!
portfolio
Rotem Shiffman
Tel Aviv, Israel
 
Join Date: Jul 2005
Posts: 2,840
try using a #postSystemStartup callback.
 
Old 04-30-2013, 03:18 PM   #3
namoi
Veteran
 
Join Date: Oct 2004
Posts: 65
Hm, but the toggle is located in the statubar, and the initial state of the toggle (on ischecked do...) must be true or false at the moment the script is evaluated (which cause the error, because my variable, the style of the active viewport, is still undefined)...
I don't see how I can handle this with a callback... Any idea ?
 
Old 04-30-2013, 03:24 PM   #4
PiXeL_MoNKeY
Expert
 
PiXeL_MoNKeY's Avatar
Eric Craft
Dallas, USA
 
Join Date: Mar 2002
Posts: 5,669
You can wrap it in a try/catch. Or you can use the PostSytemStartup to define a variable as true, and have the Macroscript only evalute/available if that PSS callback variable is true.

-Eric
__________________
"The Evil Monkey hiding in your closet."
 
Old 04-30-2013, 03:33 PM   #5
namoi
Veteran
 
Join Date: Oct 2004
Posts: 65
Quote:
Originally Posted by PiXeL_MoNKeY
You can wrap it in a try/catch. Or you can use the PostSytemStartup to define a variable as true, and have the Macroscript only evalute/available if that PSS callback variable is true.

-Eric


Thanks, the first one i used it, but it doesn't solve the problem as the toggle doesn't switch to the correct state (it only avoid throwing errors at startup).

The second seems the way to go and i was looking in that direction but i have absolutely no idea how i could use the PostSytemStartup callback to postpone the evaluation of this particular macroscript. Any clues would be greatly apreciated.

Thanks again
 
Old 04-30-2013, 03:56 PM   #6
PiXeL_MoNKeY
Expert
 
PiXeL_MoNKeY's Avatar
Eric Craft
Dallas, USA
 
Join Date: Mar 2002
Posts: 5,669
You could try something like this:
Code:
callbacks.addscript #postSystemStartup "PSScb = MacroName.isenabled = true" -- enable the button and code callbacks.addscript #preSystemShutdown "PSScb = MacroName.isenabled = false" -- disable the button and code Macroscript MacroName ( if PSScb do ( --Macro code here ) )


-Eric
__________________
"The Evil Monkey hiding in your closet."
 
Old 05-02-2013, 09:50 AM   #7
namoi
Veteran
 
Join Date: Oct 2004
Posts: 65
Hi,

Thanks and sorry for my late answer : i wasn't "online" yesterday.

I have tried your code, but it doesn't work : my guess is that the macroscript name can't be used as it is not a variable... or i am too much dumb to implement this correctly.

I have no clues
 
Old 05-02-2013, 01:24 PM   #8
namoi
Veteran
 
Join Date: Oct 2004
Posts: 65
Ok, I succeeded and the solution was finally in fact easy :

It indeed works when using a #postSystemStartup callback which trigger the function evaluating the style of the viewport (shaded or realistic). But the callback script must be located in the startup script folder.

To make the toggle dynamic, ie : when clicking another viewport, the toggle must reflect the style of that viewport, i just created another #viewportChange callback which update the toolbar buttons. This part is a little dirty, but i couldn't find another way for the macroscipt to be re evaluated.

Thanks peoples for puting me on ther right track
 
Old 05-02-2013, 01:24 PM   #9
CGTalk Moderation
Expert
CGTalk Forum Leader
 
Join Date: Sep 2003
Posts: 1,066,478
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 01:12 AM.


Powered by vBulletin
Copyright ©2000 - 2016, Jelsoft Enterprises Ltd.