Python nuke.allNodes() Examples
The following are 21
code examples of nuke.allNodes().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
nuke
, or try the search function
.
Example #1
Source File: toggle_stamp.py From NukeToolSet with MIT License | 6 votes |
def toggleStamp(): sel = nuke.selectedNodes() if len(sel): toggleVal = True for n in sel: if n.knob('postage_stamp') != None: toggleVal = not bool(n.knob('postage_stamp').getValue()) break for node in sel: if node.knob('postage_stamp') != None: node.knob('postage_stamp').setValue(toggleVal) else: nodes = nuke.allNodes() toggleVal = True for n in nodes: if n.knob('postage_stamp') != None: toggleVal = not bool(n.knob('postage_stamp').getValue()) break for node in nodes: if node.knob('postage_stamp') != None: node.knob('postage_stamp').setValue(toggleVal)
Example #2
Source File: cryptomatte_utilities.py From NukeToolSet with MIT License | 6 votes |
def _force_update_all(): with nuke.root(): node_count = 0 for node in nuke.allNodes(): if node.Class() == "Cryptomatte": node_count = node_count + 1 cinfo = CryptomatteInfo(node) _update_cryptomatte_gizmo(node, cinfo, force=True) nuke.message("Updated %s cryptomatte gizmos." % node_count) ############################################# # Utils - Update Gizmi #############################################
Example #3
Source File: switch_shot.py From NukeToolSet with MIT License | 6 votes |
def replace_shot(self, current_shot, new_shot, sep): all_read_node = nuke.allNodes('Read') if all_read_node: replace_task = nuke.ProgressTask("AAS | Replacing Files") value = 1 for read_node in nuke.allNodes('Read'): replace_task.setProgress(100/len(all_read_node)*value) file_name = read_node['file'].getValue() new_file_name = re.sub(current_shot, new_shot, file_name) new_file_dir = os.path.dirname(new_file_name) if os.path.isdir(new_file_dir): read_node['file'].setValue(self.get_frame_profile(new_file_dir, sep)) read_node['disable'].setValue(0) start_frame, end_frame = self.get_frame_range(new_file_dir, sep) self.fix_read_node(read_node, start_frame, end_frame) else: read_node['disable'].setValue(1) value += 1 replace_task.setProgress(100)
Example #4
Source File: single_to_sequence.py From NukeToolSet with MIT License | 6 votes |
def main(): for read_node in nuke.allNodes('Read'): file_name = read_node['file'].getValue().replace('\\', '/') folder = os.path.dirname(file_name) all_frames = get_frames(folder) if all_frames: replaced_frame = re.sub(r'\.\d{4}', '.%04d', all_frames[0]) frame_ext = os.path.join(folder, replaced_frame) frame_ext = frame_ext.replace('\\', '/') if file_name == frame_ext: continue read_node['file'].setValue(frame_ext) frames = get_frame_range(all_frames) if frames: start_frame, end_frame = frames rebuild_read_node(read_node, start_frame, end_frame)
Example #5
Source File: pipeline.py From core with MIT License | 6 votes |
def ls(): """List available containers. This function is used by the Container Manager in Nuke. You'll need to implement a for-loop that then *yields* one Container at a time. See the `container.json` schema for details on how it should look, and the Maya equivalent, which is in `avalon.maya.pipeline` """ all_nodes = nuke.allNodes(recurseGroups=False) # TODO: add readgeo, readcamera, readimage nodes = [n for n in all_nodes] for n in nodes: log.debug("name: `{}`".format(n.name())) container = parse_container(n) if container: yield container
Example #6
Source File: toggle_input.py From NukeToolSet with MIT License | 5 votes |
def toggleInput(): sel = nuke.selectedNodes() if len(sel): toggleVal = not bool(sel[0].knob('hide_input').getValue()) for node in sel: if node.knob('hide_input') != None: node.knob('hide_input').setValue(toggleVal) else: nodes = nuke.allNodes() toggleVal = not bool(nodes[0].knob('hide_input').getValue()) for node in nodes: if node.knob('hide_input') != None: node.knob('hide_input').setValue(toggleVal)
Example #7
Source File: cryptomatte_utilities.py From Cryptomatte with BSD 3-Clause "New" or "Revised" License | 5 votes |
def decryptomatte_all(ask=True): decryptomatte_nodes(nuke.allNodes(), ask)
Example #8
Source File: cryptomatte_utilities.py From Cryptomatte with BSD 3-Clause "New" or "Revised" License | 5 votes |
def _force_update_all(): with nuke.root(): node_count = 0 for node in nuke.allNodes(): if node.Class() == "Cryptomatte": node_count = node_count + 1 cinfo = CryptomatteInfo(node, reload_metadata=True) _update_cryptomatte_gizmo(node, cinfo, force=True) nuke.message("Updated %s cryptomatte gizmos." % node_count)
Example #9
Source File: nukeEnv.py From anima with MIT License | 5 votes |
def get_main_write_nodes(self): """Returns the main write node in the scene or None. """ # list all the write nodes in the current file all_main_write_nodes = [] for write_node in nuke.allNodes("Write"): if write_node.name().startswith(self._main_output_node_name): all_main_write_nodes.append(write_node) return all_main_write_nodes
Example #10
Source File: relativeFilePath.py From NukeToolSet with MIT License | 5 votes |
def doIt(self): nodesToProcess = nuke.selectedNodes() if self.nodeSelectionChoice.currentIndex() == 1 else nuke.allNodes() processFunction = makeNodesAbsolute if self.commandTypeChoice.currentIndex() == 1 else makeNodesRelative filteredNodes = self.filterByNodeType(nodesToProcess) choosenKnobTypes = self.collectChoosenTypes(self.supportedKnobTypes) result = processFunction(filteredNodes,choosenKnobTypes) self.warningsText.setText("\n\n".join(result['warnings'])) self.resultsText.setText("\n".join(result['replacements']))
Example #11
Source File: replace_read_node_path.py From NukeToolSet with MIT License | 5 votes |
def do_replace(self): source_path = str(self.source_le.text()) target_path = str(self.target_le.text()) for node in nuke.allNodes('Read'): node_file_path = node['file'].getValue() if source_path in node_file_path: new_path = node_file_path.replace(source_path, target_path) node['file'].setValue(new_path)
Example #12
Source File: switch_shot.py From NukeToolSet with MIT License | 5 votes |
def get_current_project_dir(self): all_dirs = list() if not nuke.allNodes('Read'): return for read_node in nuke.allNodes('Read'): file_name = read_node['file'].getValue() file_dir_name = os.path.dirname(os.path.dirname(file_name)) all_dirs.append(file_dir_name) all_dirs = list(set(all_dirs)) return all_dirs
Example #13
Source File: switch_shot.py From NukeToolSet with MIT License | 5 votes |
def import_pictures(self, sequence_dir, sep): all_read_file = [read_node['file'].getValue() for read_node in nuke.allNodes('Read')] all_read_file = list(set(all_read_file)) start_frame, end_frame = self.get_frame_range(sequence_dir, sep) read_file_name = self.get_frame_profile(sequence_dir, sep) if read_file_name: read_file_name = read_file_name.replace('\\', '/') if all((start_frame, end_frame)) and read_file_name not in all_read_file: read_node = nuke.nodes.Read(file=read_file_name) self.fix_read_node(read_node, start_frame, end_frame) nuke.zoom(1, [read_node.xpos(), read_node.ypos()])
Example #14
Source File: cryptomatte_utilities.py From NukeToolSet with MIT License | 5 votes |
def decryptomatte_all(ask=True): decryptomatte_nodes(nuke.allNodes(), ask)
Example #15
Source File: validate_write_node.py From pyblish-bumpybox with GNU Lesser General Public License v3.0 | 5 votes |
def process(self, instance): import nuke # Validate no other node is called ""{instance name}_review" node_name = "{0}_review".format(instance.data["name"]) msg = "Can not have a node called \"{0}\".".format(node_name) for node in nuke.allNodes(): assert node.name() != node_name, msg
Example #16
Source File: validate_write_node.py From pyblish-bumpybox with GNU Lesser General Public License v3.0 | 5 votes |
def process(self, instance): import os import nuke current = instance[0]["file"].getValue() expected = self.get_expected_value(instance) msg = "Output path for \"{0}\"." msg += " Current: \"{1}\". Expected: \"{2}\"" assert current == expected, msg.format( instance[0].name(), current, expected ) # Validate metadata knob if "metadata" in instance[0].knobs().keys(): msg = "Metadata needs to be set to \"all metadata\"." assert instance[0]["metadata"].value() == "all metadata", msg # Validate file type msg = "Wrong file type \"{0}\" selected for extension \"{1}\"" ext = os.path.splitext(current)[1][1:] file_type = instance[0]["file_type"].enumName( int(instance[0]["file_type"].getValue()) ) assert file_type == ext, msg.format(file_type, ext) # Validate no other node is called ""{instance name}_review" node_name = "{0}_review".format(instance.data["name"]) for node in nuke.allNodes(): assert node.name() != node_name
Example #17
Source File: nodes.py From dpa-pipe with MIT License | 5 votes |
def update_all_read_sub_nodes(): read_sub_nodes = [node for node in nuke.allNodes( filter='Read') if node.knob('product_repr_select')] repr_str_list = [DEFAULT_REPR_STR] repr_str_list.extend(sorted(PRODUCT_REPR_STR_TO_PATH.keys())) print "UPDATING: " + str([n.name() for n in read_sub_nodes]) for node in read_sub_nodes: product_repr_select = node.knob('product_repr_select') product_seq_select = node.knob('product_seq_select') cur_repr_value = product_repr_select.value() cur_seq_value = product_seq_select.value() product_repr_select.setValues(repr_str_list) if cur_repr_value in repr_str_list: product_repr_select.setValue(cur_repr_value) read_sub_knob_changed(node=node, knob=product_repr_select) seq_values = product_seq_select.value() if cur_seq_value in seq_values: product_seq_select.setValue(cur_seq_value) else: product_repr_select.setValue(DEFAULT_REPR_STR) nuke.callbacks.addKnobChanged(read_sub_knob_changed, nodeClass='Read', node=node) # -----------------------------------------------------------------------------
Example #18
Source File: collect_backdrops.py From pyblish-bumpybox with GNU Lesser General Public License v3.0 | 4 votes |
def process(self, context): import os import nuke # creating instances per backdrop node for node in nuke.allNodes(): if node.Class() != "BackdropNode": continue name = node["name"].getValue() instance = context.create_instance(name=name) instance.add(node) instance.data["families"] = ["local", "backdrop"] instance.data["family"] = "scene" label = "{0} - {1} - {2}".format(name, "scene", "local") instance.data["label"] = label # Adding/Checking publish attribute if "publish" not in node.knobs(): knob = nuke.Boolean_Knob("publish", "Publish") knob.setValue(False) node.addKnob(knob) # Compare against selection selection = instance.context.data.get("selection", []) publish = bool(node["publish"].getValue()) if selection: if list(set(instance) & set(selection)): publish = True else: publish = False instance.data["publish"] = publish # Generate output path directory = os.path.join( os.path.dirname(instance.context.data["currentFile"]), "workspace" ) scene_name = os.path.splitext( os.path.basename(instance.context.data["currentFile"]) )[0] instance.data["output_path"] = os.path.join( directory, "{0}_{1}.nk".format(scene_name, instance.data["name"]) ) def instanceToggled(instance, value): if instance[0].Class() == "BackdropNode": # Removing and adding the knob to support NukeAssist, where # you can't modify the knob value directly. instance[0].removeKnob(instance[0]["publish"]) knob = nuke.Boolean_Knob( "publish", "Publish" ) knob.setValue(value) instance[0].addKnob(knob) instance.data["instanceToggled"] = instanceToggled
Example #19
Source File: collect_writes.py From pyblish-bumpybox with GNU Lesser General Public License v3.0 | 4 votes |
def process(self, context): import clique import nuke instances = [] # creating instances per write node for node in nuke.allNodes(): if node.Class() != "Write": continue # Determine output type output_type = "img" if node["file_type"].value() == "mov": output_type = "mov" # Create instance instance = api.Instance(node.name()) instance.data["family"] = output_type instance.add(node) instance.data["label"] = node.name() instance.data["publish"] = False # Get frame range start_frame = int(nuke.root()["first_frame"].getValue()) end_frame = int(nuke.root()["last_frame"].getValue()) if node["use_limit"].getValue(): start_frame = int(node["first"].getValue()) end_frame = int(node["last"].getValue()) # Add collection collection = None try: path = "" if nuke.filename(node): path = nuke.filename(node) path += " [{0}-{1}]".format(start_frame, end_frame) collection = clique.parse(path) except ValueError: # Ignore the exception when the path does not match the # collection. pass instance.data["collection"] = collection instances.append(instance) context.data["write_instances"] = instances context.data["instances"] = ( context.data.get("instances", []) + instances )
Example #20
Source File: nukeEnv.py From anima with MIT License | 4 votes |
def replace_external_paths(self, mode=0): """make paths relative to the project dir """ # TODO: replace file paths if project_directory changes # check if the project_directory is still the same # if it is do the regular replacement # but if it is not then expand all the paths to absolute paths # convert the given path to tcl environment script from anima import utils def rep_path(path): return utils.relpath(self.project_directory, path, "/", "..") # get all read nodes allNodes = nuke.allNodes() readNodes = [node for node in allNodes if node.Class() == "Read"] writeNodes = [node for node in allNodes if node.Class() == "Write"] readGeoNodes = [node for node in allNodes if node.Class() == "ReadGeo"] readGeo2Nodes = [node for node in allNodes if node.Class() == "ReadGeo2"] writeGeoNodes = [node for node in allNodes if node.Class() == "WriteGeo"] def nodeRep(nodes): """helper function to replace path values """ [node["file"].setValue( rep_path( os.path.expandvars( os.path.expanduser( node["file"].getValue() ) ).replace('\\', '/') ) ) for node in nodes] nodeRep(readNodes) nodeRep(writeNodes) nodeRep(readGeoNodes) nodeRep(readGeo2Nodes) nodeRep(writeGeoNodes)
Example #21
Source File: collect_write_geo.py From pyblish-bumpybox with GNU Lesser General Public License v3.0 | 4 votes |
def process(self, context): import os import nuke instances = [] # creating instances per write node for node in nuke.allNodes(): if node.Class() != "WriteGeo": continue # Create cache instance instance = api.Instance(node.name()) instance.data["family"] = "cache" instance.data["families"] = ["writegeo"] instance.add(node) instance.data["label"] = node.name() instance.data["publish"] = False instance.data["output_path"] = nuke.filename(node) instances.append(instance) # Create camera instance instance = api.Instance(node.name()) instance.data["family"] = "camera" instance.data["families"] = ["writegeo"] instance.add(node) instance.data["label"] = node.name() instance.data["publish"] = False path, ext = os.path.splitext(nuke.filename(node)) instance.data["output_path"] = "{0}_camera{1}".format(path, ext) instances.append(instance) # Create geometry instance instance = api.Instance(node.name()) instance.data["family"] = "geometry" instance.data["families"] = ["writegeo"] instance.add(node) instance.data["label"] = node.name() instance.data["publish"] = False path, ext = os.path.splitext(nuke.filename(node)) instance.data["output_path"] = "{0}_geometry{1}".format(path, ext) instances.append(instance) context.data["instances"] = ( context.data.get("instances", []) + instances )