[Closed] Layer Rename Callback
Hi, was looking to see if there was a way of either preventing layer renaming or at least flagging it. An earlier post here mentions it, only it doesn’t appear to work as hoped.
http://forums.cgsociety.org/showthread.php?f=98&t=860786
DenisT, could you kindly elaborate on how to get the when construct working with this? the help suggests that the name[s] change handler is –
Signaled when the name of an object is changed if this occurs because a user edits the name in one of the 3ds Max command panels. The handler is called repeatedly with each character that is changed.
I thought maybe its not working as the layer manager is not classed as a command panel??
I’ve been looking into this for a long time (as you noticed in that other thread) and never found a solution to get a rename event. I use a when construct to get some other property changes to work:
when parameters layer change id:#outliner_layers layer do outliner_callbacks.layerParametersChanged layer;
This does not work for the name however. I think that somewhere in the implementation of them, they forgot to fire the event.
Hi Pier,
Yes it’s been on my wishlist for a while too, I’ll flag it as a bug in the beta forum. Thanks.
What you could if it was critical to get this callback, and you felt like going the really long and hard way around things, is create a c# class that wraps a nativeWindow class, get the handle of the layer window using dialogMonitorOps, feed that to the c# class, and override it’s WndProc event. in the WndProc event, listen for text changed messages.
Create a delegate that will launch an event in the c# class, and register this event in maxscript.
Needless to say this idea is not tested but I have had success listening to other Win32 messages using NativeWindow
usually people need the layer rename event (or callback) for custom Layer Manager to replace the built-in Layer Managed Dialog.
The problem is:
name property is not really a parameter of layer. (it’s why its changing doesn’t fire event on when name(parameters) change).
setname method sends notification directly to LayerManager interface. If the Layer Manager Dialog is open the interface updates its UI. It creates an illusion that max has some hidden (unknown, undocumented, etc.) event (or callback) to use. If the dialog is closed we can’t catch any message about layer renaming.
http://forums.cgsociety.org/showpost.php?p=6409456&postcount=2
there are my apologizes. There is no any known for me callback or event in mxs fired by layer renaming.
Not a problem, no apology necessary Denis!
(and thanks for the idea, Lo)
Not sure I understand what you are saying…
Is the problem:
a) no way to catch when a user has manually changed a name in the max layer manager?
or
b) something else?
alright, but under what circumstances can that happen? How can one change the layer name if not by script and not via the layer manager?
The layer name is read-only for script access.
Due to the docs – they worried from scripters that can put dups names, hehe…
i don’t have max opened but it should be:
(layermanager.getlayer 1).setname "test"