Yep, the "Executable" node baseclass seems to add those knobs, so it should be a reasonably reliable way to find executable nodes

Of course it could still find non-executable nodes, e.g if someone adds beforeRender knob to their gizmo, so you'd may still want to catch the RuntimeError("Blur1 cannot be executed") exception,

try:
    nuke.execute(node, ...)
except RuntimeError, e:
    if str(e).endswith("cannot be executed"):
        ...handle error...
    else:
        raise

(incidentally, trying to execute the node is one reliable way to check if a node is executable..)

It would be worth a feature-request for a Node.isExecutable method - Nuke already has the information, it's just not exposed to Python

On 11/10/13 00:11, Frederich Munch wrote:
Not authoritative; but I just checked a custom node that is Executable
and indeed a 'beforeRender' knob is added by Nuke.

------------------------------------------------------------------------
From: [email protected]
Date: Thu, 10 Oct 2013 08:05:20 -0300
Subject: Re: [Nuke-python] How to check if a Node is executable?
To: [email protected]

nuke.allNodes('Write') will only return nodes of the Write Class, so
just "Write" nodes. Many other nodes (classes) can be executed, like
GenerateLUT, CurveTool, WriteGeo, DeepWrite, etc.

I think it's a safe bet to check for the existence of knob named "before
render", otherwise you would have to check for knobs named "go",
"render", "execute", "generate", etc which would be odd.

Personally I don't know of any other way to identify executable nodes
aside that one at least.


cheers,
Diogo


On Thu, Oct 10, 2013 at 6:14 AM, Fredrik Averpil
<[email protected] <mailto:[email protected]>> wrote:

    Aren't executable nodes always of type Write?

    If so, this could be what you're looking for?


    Select some node and run the script to check whether it's executable
    or not.



    [snip]


    def isExecNode( someNode ):

    execNodes = nuke.allNodes('Write')

    print execNodes

    for execNode in execNodes:

    if someNode.name() in execNode.name():

    return True

    else:

    return False




    if isExecNode( nuke.selectedNode() ):

    print 'Execute node: ' + nuke.selectedNode().name()

    else:

    print 'Do not execute node: ' + nuke.selectedNode().name()


    [/snip]





    Regards,

    Fredrik





    On Thu, Oct 10, 2013 at 3:38 AM, Paul Hudson <[email protected]
    <mailto:[email protected]>> wrote:

        Hi everyone,

        Is there an official way to check if a node is executable? I was
        just going to check if it has a 'beforeRender' knob, but wasn't
        sure that covers all cases.


        As always, thanks so much!
        -Paul

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



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



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


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

--
ben dickson
2D TD | [email protected]
rising sun pictures | www.rsp.com.au
_______________________________________________
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