View Full Version : script called at the same time than a max feature
01-27-2009, 08:50 AM
Here is my question : is it possible to trigger a script at the same time than a max feature ?
For example : When i use the "Unhide All" button (or quad or whatever), is it possible to trigger a script that tells max to display shading without textures (for memory issues). It would be okay to rewrite a simple maxscript that allows to unhide all AND setting the shading mode at the same time, but i wondered if it would be possible without rewriting functions (which would be much more complex than juste "unhide all")
01-27-2009, 09:37 AM
Unless the command performed is a scripted command (via a macroscript) to begin with, there's no real way to rewrite what the command does.
You can, however, detect or deduce some things. For detection, go to the Index tab of the help file and type "callbacks". You should get a little list with "callbacks" "and change handlers", "general event", "time change", "viewport redraw". In addition to these, in 3ds Max 2009, there is the Node Event System. That one would apply particularly to your example, as it allows you to detect when objects get hidden/unhidden.
You wouldn't be able to prevent an object from being unhidden, for example, though - so you can't rewrite that actual command. You could re-hide it after it was unhidden, of course.
Beyond those, you can always set up a timer (rollout or .net) to essentially monitor scene changes manually - understanding that there will always be a slight delay between the user's actual action and your monitor running.
If none of the above are appropriate then you really are stuck with writing your own script to do what you need - and, of course, instructing users of your tools not to use max's built-in functionality that you are 'replacing'.
If you have anything more specific in mind, feel free to ask - would make it easier to assess whether you can use the stuff above or not.
01-27-2009, 09:57 AM
Hi Richard and thanks for your answer. Currently we are working under max8 and max9 versions so we don't have access to the Node event system. I think that a .net monitor would be a little heavy or too long to code for me.
What I want is simple :
When I quit an isolate selection or when I unhide all objects, I would like them to be displayed in object color. So i thought about replacing the Unhide All quad command (which I use) by a custom script which would first set the display mode to object color followed by the "max unhide all" command. Curiously I didn't find the maxscript command for "object color/material color" shading mode.
01-27-2009, 10:22 AM
it's a bit hidden away, but you are looking for the help topic...
Display Panel: Wireframe and Shaded Colors
And yes - creating a macro that does what you mention would be simple :)
01-27-2009, 10:22 AM
I don't know if there's a command to turn off all textures at once, but you can use "showTextureMap = false" in a loop where you cycle through all your materials.
01-27-2009, 10:31 AM
Thanks Richard, i passed by this help topic and I thought first it was a method related to objects instead of viewports.
I already used a similar method, but it's a little bit heavy...
01-27-2009, 03:51 PM
Not sure about Max 8 and 9, but more recent versions do have actions assigned for: Standard Display, Standard Dislpay with Maps, Hardware Display, and Hardware Display with Maps. Those commands are accessible from the MatEditor > Material > Show Materials in Viewport As.actionMan.executeAction 0 "63510" -- Views: Standard Display
actionMan.executeAction 0 "63509" -- Views: Hardware Display with Maps-Eric
01-27-2009, 05:22 PM
Finally I went by the shortest and easiest way : a quad menu item replacing the Unhide All command :
displaycolor.shaded = #object -- To avoid loading maps
freescenebitmaps() -- To free maps from memory
max unhide all -- The command itself
01-27-2009, 05:22 PM
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.
vBulletin v3.0.5, Copyright ©2000-2015, Jelsoft Enterprises Ltd.