Well, callback functions are always run in the context of the node they are attached to, so from the callback’s point of view, the Gizmo is the correct context to run code in.
It’s sort of similar to a namespace in programming; in order to see things that aren’t children of the namespace, you need to make explicit references to them, otherwise many of the functions in Nuke that run in the active context (nuke.selectedNode, nuke.selectedNodes, nuke.allNodes, nuke.toNode, etc.) will only know to look downward from (or relative to) the current 'namespace' when operating on nodes or finding nodes. -Nathan From: Brogan Ross Sent: Tuesday, September 20, 2011 7:08 PM To: Nuke Python discussion Subject: Re: [Nuke-python] Gizmo onCreate callback going inside gizmo Thanks Nathan that worked like a charm. I wonder why Nuke would think that I wanted to look through the gizmo by default, instead of the root(). Oh well, thanks a lot for the help. Brogan On Tue, Sep 20, 2011 at 6:42 PM, Nathan Rusch <nathan_ru...@hotmail.com> wrote: You can pass nuke.allNodes a node to use as an execution context. If you know you always want to look at the top-level of your comp, just use: nuke.allNodes(group=nuke.root()) If you want to look at the container context of the new gizmo regardless of whether it’s the root node or not, use: nuke.allNodes(group=nuke.thisParent()) Obviously if the given 'parent' gizmo you’re looking for could be anywhere, you’ll need to walk from nuke.root() into every Group node. -Nathan From: Brogan Ross Sent: Tuesday, September 20, 2011 6:34 PM To: Nuke Python discussion Subject: [Nuke-python] Gizmo onCreate callback going inside gizmo So I found this interesting little tidbit that I didn't want to happen. Basically, I have an onUserCreate callback to expression the values of a given "parent" gizmo to the newly created gizmo. But when I'm doing a search for the "parent" gizmo with nuke.allNodes() the callback is looking at the innards of the newly created gizmo. def gizmoCallback(): newgizmo = nuke.thisNode() for node in nuke.allNodes(): if node.Class() in ["list", "of", "possible", "matches"]: if node.name().split()[0].lower() == "searchTag": newgizmo.setExpressions() nuke.onUserCreate(gizmoCallback, nodeClass='NewGizmo') That's basically what I'm running, but if I have it print out the nodes in nuke.allNodes() it prints the names of the nodes inside the gizmo. Anyone else run it this before? Any work arounds? Thanks, Brogan ------------------------------------------------------------------------------ _______________________________________________ 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