[Closed] Scene State switching detection
Hi!
Is there some way to detect scene state switching in maxscript? There’s no associated callback, but may be there is some other way? I’ve tryed to use [b][b]#nodeHide callback, but can’t find callbacks firing when layer state are changing.
Thank you,
Sergo.
[/b][/b]
there is no special “scene state” changed callback. Restoring the scene state might cause a lot of changes or no one. There is no way to say how these changes were happened (through sceneStateMgr interface, using other script, from max UI, etc.). You can’t catch the cause of changes but can catch the effect.
For example, if you want to catch Layer’s properties changing you can use when construct for layer’s ReferenceTarget:
eh = when parameters LayerManager.current.layerAsRefTarg change do print "Layer properties"
-- deleteChangeHandler eh
Thank you, Denis! This is what I need.
Will it be a big overhead to assign when construct to all (10-100) layers?
That’s no a problem to handle many layers with when construct. The problem is how to register change handlers for newly created (or merged, or xref-ed) layers. For created layers you have to listen #layerCreated callback, for merged layers – #filePostMerge (or #filePostMergeProcess), etc.
You don’t need to take care about deleted layers. MAX automatically deletes all change handlers for all deleted objects.
I’m writing layer management script, so I’ll add when constructs to newly created layers in script itself.
Thank you for the tip Denis!