Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Python

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

 

 

Python python RSS feed   Index | Next | Previous | View Threaded


s.deshe at gmail

Jul 9, 2009, 11:18 PM

Post #1 of 4 (282 views)
Permalink
way for a function to understand whether it's being run through a OnCreate callback or not

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


clp2 at rebertia

Jul 9, 2009, 11:23 PM

Post #2 of 4 (263 views)
Permalink
Re: way for a function to understand whether it's being run through a OnCreate callback or not [In reply to]

On Thu, Jul 9, 2009 at 11:18 PM, slamdunk<s.deshe [at] gmail> 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


gherron at islandtraining

Jul 9, 2009, 11:59 PM

Post #3 of 4 (266 views)
Permalink
Re: way for a function to understand whether it's being run through a OnCreate callback or not [In reply to]

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


martin at librador

Jul 10, 2009, 12:30 AM

Post #4 of 4 (266 views)
Permalink
Re: way for a function to understand whether it's being run through a OnCreate callback or not [In reply to]

On Fri, Jul 10, 2009 at 8:18 AM, slamdunk<s.deshe [at] gmail> 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


--
martin [at] librador
http://www.librador.com
--
http://mail.python.org/mailman/listinfo/python-list

Python python RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.