View Full Version : MEL node context
11-23-2006, 10:10 PM
I have my own custom node, and have different instances of that node. This node is connected to a mesh.
Inside that node, I have a button that can load and apply a texture to its connected mesh.
Node1 -> Mesh1
Node2 -> Mesh2
So if I have a button that calls a mel script, how can I get mel to return the context where it was pushed?
Eg if I push the button inside Node2's attribute editor, what line of mel code will return the name "Node2"?
Should be an easy solution, just slightly tricky to explain
11-23-2006, 10:32 PM
First of all a word of advice: never change anything in the dependency graph within the compute function of your node. this is braking one of maya's fundamental principles that each node only deals with its own plugs and data and never uses anything for which it doesn't have any explicit input. even though maya's api is not very strict and allows you to do something like this - changing the state of the dg in the way you describe will almost certainly get you into trouble at some point as your basicly messing up the dirty flag propagation.
So what you could do instead is to to the modification with a mel script. Either your currently selected node or attach your script to a custom control in your node's AETemplate. You know which node you are currently displaying in the AE, because you updated the UI (and your button) with the AEmyControlReplace function which gets automaticly called from maya with the nodeAttr (which you can simply tokenize to get the node name).
Hope this helps,
11-24-2006, 12:34 AM
>> attach your script to a custom control in your node's AETemplate. You know which node you are currently displaying in the AE, because you updated the UI (and your button) with the AEmyControlReplace function which gets automaticly called from maya with the nodeAttr (which you can simply tokenize to get the node name).
Yeah, thats what im doing already, i just didnt explain it very well. Everythings in MEL, with regard to the button.
Sweet, thanks, I'll try what you said and get back to you.
Here's my AEtemplate, i assume i can just modify this to pass the $nodeName parameter to initTFW method (the one with the button). InitTFW mel procedure exists elsewhere...
global proc AEHFNodeTemplate ( string $nodeName )
editorTemplate -beginLayout "Attributes" -collapse 0;
editorTemplate -addControl "View_Detail";
editorTemplate -addControl "Render_Detail";
editorTemplate -addControl "Camera_Ratio";
editorTemplate -addControl "at_Origin";
editorTemplate -callCustom init_TFW refresh_TFW;
11-24-2006, 12:34 AM
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.