Anyone still following this, here's what's going on: node paste does in
fact trigger the onCreate. What *doesn't* work is specifically setting a
node's input in an onCreate function when pasting.That was throwing me off.
For example, if I have a node in the DAG called 'foo' and this in my
menu.py...

###
def testSetInputOnCreate():
    print 'Running test set input on create function'
    n = nuke.toNode('foo')
    if n:
        nuke.thisNode().setInput(0, n)

nuke.addOnCreate(testSetInputOnCreate, nodeClass='Dot')
###

Create a Dot node (i.e. through the toolbar) and its input will set
correctly to 'foo'. But, if you copy and paste that same Dot node, its
input won't set. This seems like a bug. Then I tried running the function
in a thread timed with a .25 second delay. That does work.

So, for now, my problem is solved (somewhat inelegantly). Sending in a bug
report...

Cheers

On Thu, May 24, 2012 at 2:58 PM, Ean Carr <eanc...@gmail.com> wrote:

> Hmm, now it looks like onCreate isn't triggered by node paste. I thought
> it used to be... (?). Nuke 6.3v6. Can anyone verify on their end? Thanks,
> Ean
>
>
> On Thu, May 24, 2012 at 9:24 AM, Ean Carr <eanc...@gmail.com> wrote:
>
>> Hey Diogo, good idea. That should be faster than what I was doing. Will
>> give it a shot. Thanks, -Ean
>>
>>
>> On Thu, May 24, 2012 at 7:48 AM, Diogo Girondi <diogogiro...@gmail.com>wrote:
>>
>>> Hi Ean,
>>>
>>> If it's a custom node you can add a hidden boolean knob that gets set to
>>> True after the node has been processed the first time. And in you script
>>> routine you check for that knob's value before doing any further
>>> processing, so any node with that set is ignored. It's a hack, but it tends
>>> to work and I use for certain things here.
>>>
>>> Having more granular callbacks would be better though.
>>>
>>>
>>> cheers,
>>> diogo
>>>
>>>
>>> On Wed, May 23, 2012 at 6:50 AM, Ean Carr <eanc...@gmail.com> wrote:
>>>
>>>> Okay, made feature request for two callbacks (logged as #27725):
>>>>
>>>> beforePaste: called before data is dropped to DAG
>>>> afterPaste: called after data is dropped to DAG
>>>>
>>>> Diogo, I have a special node whose input needs to be set to a specific
>>>> dependency automatically on copy/paste. Sticking the code in an onCreate
>>>> works when copy/pasting, but has the side effect of also running on script
>>>> load, which is too slow on loading larger scripts as it loops through
>>>> everything, checking for my special nodes and their inputs. Also, if the
>>>> user specifically disconnects the input, I don't want it reconnected on
>>>> script load.
>>>>
>>>> Currently I'm doing it through a drop data callback, which works, but
>>>> is less than ideal for the reasons I gave before. Any other way to do this
>>>> that you can think of?
>>>>
>>>> -Ean
>>>>
>>>>
>>>>
>>>> On Wed, May 23, 2012 at 2:50 AM, Diogo Girondi 
>>>> <diogogiro...@gmail.com>wrote:
>>>>
>>>>> I agree, a onPaste() would probably be welcome.
>>>>>
>>>>> What are you trying to do exactly? Maybe there is another way to
>>>>> handle it.
>>>>>
>>>>>
>>>>> cheers,
>>>>> diogo
>>>>>
>>>>>
>>>>> On Tue, May 22, 2012 at 3:36 AM, Ean Carr <eanc...@gmail.com> wrote:
>>>>>
>>>>>> Hey Diogo,
>>>>>>
>>>>>> Problem with onCreate is it's too broad in its reach: also triggered
>>>>>> when a script loads or when a node's created from the toolbar, etc.
>>>>>>
>>>>>> Doing what I need via a drop data callback is my current hack, but
>>>>>> means I have to deal with the rest of the stack if all I'm after is one
>>>>>> node. This could work, though, if I could extract my part of the text,
>>>>>> return True on that, but return None on the rest so Nuke deals with it. 
>>>>>> Is
>>>>>> that possible?
>>>>>>
>>>>>> Thanks,
>>>>>> Ean
>>>>>>
>>>>>> On Mon, May 21, 2012 at 2:17 PM, Diogo Girondi <
>>>>>> diogogiro...@gmail.com> wrote:
>>>>>>
>>>>>>> In theory onCreate() should catch any clipboard paste.
>>>>>>>
>>>>>>> The addDropDataCallback() also catches stuff pasted from the
>>>>>>> clipboard depending on what you need to do.
>>>>>>>
>>>>>>> Hop this helps.
>>>>>>>
>>>>>>>
>>>>>>> cheers,
>>>>>>> diogo
>>>>>>>
>>>>>>> On Mon, May 21, 2012 at 9:48 AM, Ron Ganbar <ron...@gmail.com>wrote:
>>>>>>>
>>>>>>>> There should be something.
>>>>>>>> Otherwise how does the paste into the DAG work?
>>>>>>>>
>>>>>>>> R
>>>>>>>> On May 21, 2012 1:12 PM, "Ean Carr" <eanc...@gmail.com> wrote:
>>>>>>>>
>>>>>>>>>  Hi,
>>>>>>>>>
>>>>>>>>> Would really like something like an onPaste callback. Anyone know
>>>>>>>>> if it exists but I'm just overlooking it? If not, will file a feature
>>>>>>>>> request.
>>>>>>>>>
>>>>>>>>> Cheers,
>>>>>>>>> Ean
>>>>>>>>>
>>>>>>>>> _______________________________________________
>>>>>>>>> Nuke-python mailing list
>>>>>>>>> Nuke-python@support.thefoundry.co.uk,
>>>>>>>>> http://forums.thefoundry.co.uk/
>>>>>>>>>
>>>>>>>>> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
>>>>>>>>>
>>>>>>>>>
>>>>>>>> _______________________________________________
>>>>>>>> Nuke-python mailing list
>>>>>>>> Nuke-python@support.thefoundry.co.uk,
>>>>>>>> http://forums.thefoundry.co.uk/
>>>>>>>> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>> _______________________________________________
>>>>>>> Nuke-python mailing list
>>>>>>> Nuke-python@support.thefoundry.co.uk,
>>>>>>> http://forums.thefoundry.co.uk/
>>>>>>> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
>>>>>>>
>>>>>>>
>>>>>>
>>>>>> _______________________________________________
>>>>>> Nuke-python mailing list
>>>>>> Nuke-python@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/
>>>>>> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
>>>>>>
>>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> Nuke-python mailing list
>>>>> Nuke-python@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/
>>>>> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
>>>>>
>>>>>
>>>>
>>>> _______________________________________________
>>>> Nuke-python mailing list
>>>> Nuke-python@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/
>>>> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
>>>>
>>>>
>>>
>>> _______________________________________________
>>> Nuke-python mailing list
>>> Nuke-python@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/
>>> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
>>>
>>>
>>
>
_______________________________________________
Nuke-python mailing list
Nuke-python@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python

Reply via email to