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

2009-07-10 Thread 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.
-- 
http://mail.python.org/mailman/listinfo/python-list


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

2009-07-10 Thread Chris Rebert
On Thu, Jul 9, 2009 at 11:18 PM, slamdunks.de...@gmail.com wrote:
 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
-- 
http://blog.rebertia.com
-- 
http://mail.python.org/mailman/listinfo/python-list


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

2009-07-10 Thread Gary Herron

slamdunk wrote:

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

--
http://mail.python.org/mailman/listinfo/python-list


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

2009-07-10 Thread Martin Vilcans
On Fri, Jul 10, 2009 at 8:18 AM, slamdunks.de...@gmail.com wrote:
 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


-- 
mar...@librador.com
http://www.librador.com
-- 
http://mail.python.org/mailman/listinfo/python-list