Calling Function from Maya #129
-
How do I call a function which is declared on one node from an anther node? or a function which is already being declared on the Maya terminal. MayaCodeEditor or NXT Node1 > def test():
print('Test function') NXT Node2 > test() Is this possible? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
There are a couple of approaches you could use.
All of these are valid ways to work, however personally I tend to use NXT to formulate function calls and orchestrate the sequence of events. So in my case I would import |
Beta Was this translation helpful? Give feedback.
There are a couple of approaches you could use.
Put your function in the World Node's code block. Function, variables, modules, ect defined in the world node are available globally. You can access the world node by double clicking the layer's name or by pressing
/
andreturn
(by default,/
brings up the node search box).You could declare the function as a global.
global test
. The global keyword allows all nodes to access the name.Callables can be stored in the
STAGE
object. So after defining the function you could do something likeSTAGE.test = test
, then call it in a later node viaSTAGE.test()
.All of these are valid ways to work, however personally I tend to use NXT to formul…