Nuke Node Type Finder

A small helper function for finding the node type from tne nuke

[Python]
import nuke

#~ node type finding small function
def find_node_type(nodeList):

“””
Small helper function for find the node type from nuke.

:param nodeList: This should be a list

:type nodeList: list

:return: nodes and node type

:rtype: dict

Example

>>> import find_node_type as fns
>>> node_to_find = [“roto_a”,”write_b”,”shuffle_mode”]
>>> node_found = fns.find_node_type(node_to_find)
>>> print node_found
>>> {‘Roto’: [‘roto_a’], ‘Write’: [‘write_b’], ‘Shuffle’:[‘shuffle_mode’]}

“””

#~ return var and this is dict type
found_nodes = {}

#~ getting all available nodes from the nuke scene file
get_nuke_node_list = nuke.root().nodes()

#~ looping throuh the list provided by user
for each_node in nodeList:

#~ loop throuh the nodes we found in the nuke scene file
for each_nd in get_nuke_node_list:

#~ getting node class type from node
node_class = each_nd.Class()
if each_nd.name().find(each_node) != -1:

#~ if the node is there in the dict then add to the list
#~ or create the key and add value
if found_nodes.has_key(node_class):
found_nodes[node_class].append(each_nd.name())
else:
found_nodes[node_class]=[]
found_nodes[node_class].append(each_nd.name())

#~ return what we found from the scene
return(found_nodes)

[/Python]

  1. No comments yet.

  1. No trackbacks yet.

Error thrown

Undefined constant "cs_print_smilies"