way for a function to understand whether it's being run through aOnCreate callback or not

S

slamdunk

is there a way for a function to understand whether it's being run
through a OnCreate callback or not?
I have working functions that I want to recycle through the OnCreate
but need to catch the "nuke.thisNode()" bit inside them so they can
still function when called manually through other scripts functions.
 
C

Chris Rebert

is there a way for a function to understand whether it's being run
through a OnCreate callback or not?
I have working functions that I want to recycle through the OnCreate
but need to catch the "nuke.thisNode()" bit inside them so they can
still function when called manually through other scripts functions.

Your question lacks context. What's an OnCreate callback?

Cheers,
Chris
 
G

Gary Herron

slamdunk said:
is there a way for a function to understand whether it's being run
through a OnCreate callback or not?
I have working functions that I want to recycle through the OnCreate
but need to catch the "nuke.thisNode()" bit inside them so they can
still function when called manually through other scripts functions.
You've given us almost *NO* clue what you are talking about. I suppose
I could Google "onCreate", and perhaps "nuke" and "thisNode", and see
what falls out. But why would I? If you want our help, *you* take the
time to tell is what you are asking about.

You may want to start here:
http://www.catb.org/~esr/faqs/smart-questions.html#intro

Gary Herron
 
M

Martin Vilcans

is there a way for a function to understand whether it's being run
through a OnCreate callback or not?
I have working functions that I want to recycle through the OnCreate
but need to catch the "nuke.thisNode()" bit inside them so they can
still function when called manually through other scripts functions.

I suppose you're programming for The Foundry's Nuke. Python is used in
lots of different contexts, and most people on this list use Python
for something totally unrelated to video.

As an attempt at answering your question, you can add a parameter to
your function that tells from where it's called. I.e. you put True in
the parameter when it is called from OnCreate, False when it is not.
But that isn't a very good design. A function should not need to care
from where it is called. You probably want to have the node as a
parameter to the function instead of calling nuke.thisNode inside of
it.

I can't find documentation for the OnCreate function online. Do you
mean that you can only call nuke.thisNode() from inside OnCreate?

Here's my guess of what I think you want to do:

def OnCreate():
# call your function with the current node as argument
your_function(nuke.thisNode())

def your_function(node):
# The function takes a node as an argument.
# Do whatever you want here

For more Nuke-specific questions, you'd probably get better results by
asking on the Nuke-python mailing list:

http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top