PDA

View Full Version : Layer Rename Callback


LoneRobot
06-06-2011, 02:39 PM
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??

Pjanssen
06-06-2011, 02:52 PM
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.

LoneRobot
06-06-2011, 03:04 PM
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.

lo
06-06-2011, 04:12 PM
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 :)

denisT
06-07-2011, 07:45 PM
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 -



I thought maybe its not working as the layer manager is not classed as a command panel??

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.

LoneRobot
06-07-2011, 08:56 PM
Not a problem, no apology necessary Denis!

(and thanks for the idea, Lo)

denisT
06-07-2011, 11:31 PM
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.


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.

lo
06-08-2011, 01:03 AM
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?

denisT
06-08-2011, 01:13 AM
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?

there is no way to catch layer renaming when the layer manager dialog is closed

lo
06-08-2011, 11:31 AM
there is no way to catch layer renaming when the layer manager dialog is closed

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?

denisT
06-08-2011, 03:16 PM
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?

i'm talking about changing by someone else's script.

lo
06-08-2011, 04:05 PM
i'm talking about changing by someone else's script.

yup, can't think of a solution for that one... :shrug:

Panayot
06-08-2011, 11:26 PM
i'm talking about changing by someone else's script.
The layer name is read-only for script access.
Due to the docs - they worried from scripters that can put dups names, hehe...

denisT
06-08-2011, 11:32 PM
The layer name is read-only for script access.
Due to the docs - they worried from scripters that can put dups names, hehe...
the name property is read-only.
setname method sets the name.

Panayot
06-08-2011, 11:35 PM
the name property is read-only.
setname method sets the name.
thanks, you are right ;)

denisT
06-08-2011, 11:41 PM
hmm... did can prof this with a peace of code?
i don't have max opened but it should be:

(layermanager.getlayer 1).setname "test"

Panayot
06-08-2011, 11:45 PM
i don't have max opened but it should be:

(layermanager.getlayer 1).setname "test"
ya, my stupid fault, thanks!

CGTalk Moderation
06-08-2011, 11:45 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.