[Closed] script called at the same time than a max feature
Hi all,
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”)
Cheers
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.
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.
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
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.
Thanks Richard, i passed by this help topic and I thought first it was a method related to objects instead of viewports.
@ Piflik,
I already used a similar method, but it’s a little bit heavy…
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
Finally I went by the shortest and easiest way : a quad menu item replacing the Unhide All command :
macroscript UnhideAllCustom
(
displaycolor.shaded = #object -- To avoid loading maps
freescenebitmaps() -- To free maps from memory
max unhide all -- The command itself
)