Hi Chris,

Not a dumb question at all... I'm not sure this will be helpful, but if I 
understand your question, have you thought of using a callback? i.e. when the 
node is created, if input 1 is connected, do this -- if input 2 is also 
connected, do that... otherwise do something else. There are a wide range of 
callbacks you can choose from -- one will take action only when the node is 
created, another will take action when the user does "specified action", etc.

You can add your callback to your menu.py file (since it's GUI related) -- 
first you define the function your callback will execute, then you define the 
callback it... here's a pseudo example:

def mySweetFunction():
        n=nuke.thisNode()
        if n.Class()=="Read":
                print "You have just created a new Read node named %s" %n.name()

### this function will print the Read nodes name every time a new read node is 
created -- but only if you put it into action by using it in a callback

nuke.addOnCreate(mySweetFunction, nodeClass = "Read")

### Notice the lack of parentheses after my function "mySweetFunction" when I 
pass the function to call in the callback -- you are telling the callback which 
function to call, rather than calling it at that time... this something that 
can confuse people.

With regard to your question about defining variables for a node upon creation 
-- you could set knobs upon creation by sniffing for things but a callback is 
easier...

Is there a reason you prefer nuke.createNode("Node") as opposed to 
nuke.nodes.Node(name="hello",label="world")?

The second is much easier to define values inline, however both can have knob 
values defined after the node creation quite easily, like so:

myNode=nuke.createNode("NoOp")
myNode['name'].setValue("Hello") # I find this shorthand method preferable to 
the longhand equivalent: myNode.knob('name').setValue('hello')

Again, if I understand your question, I would use a callback and then tweak the 
knob values as I have described above...

Hope this helps...

Cheers,
Jep_______________________________________________
Nuke-python mailing list
[email protected], http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python

Reply via email to