def repair(cls, instance): node = instance[0] if "Write" in node.Class(): data = toml.loads(node["avalon"].value()) else: data = get_avalon_knob_data(node) # collect reusable data data["XYpos"] = (node.xpos(), node.ypos()) data["input"] = node.input(0) data["publish"] = node["publish"].value() data["render"] = node["render"].value() data["render_farm"] = node["render_farm"].value() data["review"] = node["review"].value() data["use_limit"] = node["use_limit"].value() data["first"] = node["first"].value() data["last"] = node["last"].value() family = data["family"] cls.log.debug("_ orig node family: {}".format(family)) # define what family of write node should be recreated if family == "render": Create_name = "CreateWriteRender" elif family == "prerender": Create_name = "CreateWritePrerender" # get appropriate plugin class creator_plugin = None for Creator in api.discover(api.Creator): if Creator.__name__ != Create_name: continue creator_plugin = Creator # delete the legaci write node nuke.delete(node) # create write node with creator new_node_name = data["subset"] creator_plugin(new_node_name, data["asset"]).process() node = nuke.toNode(new_node_name) node.setXYpos(*data["XYpos"]) node.setInput(0, data["input"]) node["publish"].setValue(data["publish"]) node["review"].setValue(data["review"]) node["use_limit"].setValue(data["use_limit"]) node["first"].setValue(data["first"]) node["last"].setValue(data["last"]) # recreate render targets if data["render"]: node["render"].setValue("Local") if data["render_farm"]: node["render"].setValue("On farm")
def process(self, context, plugin): # Get the errored instances failed = [] for result in context.data["results"]: if (result["error"] is not None and result["instance"] is not None and result["instance"] not in failed): failed.append(result["instance"]) # Apply pyblish.logic to get the instances for the plug-in instances = pyblish.api.instances_by_plugin(failed, plugin) for instance in instances: if "Write" in instance[0].Class(): data = toml.loads(instance[0]["avalon"].value()) else: data = get_avalon_knob_data(instance[0]) self.log.info(data) data["xpos"] = instance[0].xpos() data["ypos"] = instance[0].ypos() data["input"] = instance[0].input(0) data["publish"] = instance[0]["publish"].value() data["render"] = instance[0]["render"].value() data["render_farm"] = instance[0]["render_farm"].value() data["review"] = instance[0]["review"].value() # nuke.delete(instance[0]) task = os.environ["AVALON_TASK"] sanitized_task = re.sub('[^0-9a-zA-Z]+', '', task) subset_name = "render{}Main".format(sanitized_task.capitalize()) Create_name = "CreateWriteRender" creator_plugin = None for Creator in api.discover(api.Creator): if Creator.__name__ != Create_name: continue creator_plugin = Creator # return api.create() creator_plugin(data["subset"], data["asset"]).process() node = nuke.toNode(data["subset"]) node.setXYpos(data["xpos"], data["ypos"]) node.setInput(0, data["input"]) node["publish"].setValue(data["publish"]) node["render"].setValue(data["render"]) node["render_farm"].setValue(data["render_farm"]) node["review"].setValue(data["review"])
def process(self, context): asset_data = io.find_one({ "type": "asset", "name": api.Session["AVALON_ASSET"] }) self.log.debug("asset_data: {}".format(asset_data["data"])) instances = [] root = nuke.root() self.log.debug("nuke.allNodes(): {}".format(nuke.allNodes())) for node in nuke.allNodes(): if node.Class() in ["Viewer", "Dot"]: continue try: if node["disable"].value(): continue except Exception as E: self.log.warning(E) # get data from avalon knob self.log.debug("node[name]: {}".format(node['name'].value())) avalon_knob_data = get_avalon_knob_data(node, ["avalon:", "ak:"]) self.log.debug("avalon_knob_data: {}".format(avalon_knob_data)) if not avalon_knob_data: continue if avalon_knob_data["id"] != "pyblish.avalon.instance": continue # establish families family = avalon_knob_data["family"] families_ak = avalon_knob_data.get("families") families = list() # except disabled nodes but exclude backdrops in test if ("nukenodes" not in family) and (node["disable"].value()): continue subset = avalon_knob_data.get( "subset", None) or node["name"].value() # Create instance instance = context.create_instance(subset) instance.append(node) # Add all nodes in group instances. if node.Class() == "Group": # only alter families for render family if "write" in families_ak: if node["render"].value(): self.log.info("flagged for render") add_family = "{}.local".format(family) # dealing with local/farm rendering if node["render_farm"].value(): self.log.info("adding render farm family") add_family = "{}.farm".format(family) instance.data["transfer"] = False families.append(add_family) else: # add family into families families.insert(0, family) node.begin() for i in nuke.allNodes(): instance.append(i) node.end() self.log.debug("__ families: `{}`".format(families)) if families_ak: families.append(families_ak) else: families.append(family) # Get format format = root['format'].value() resolution_width = format.width() resolution_height = format.height() pixel_aspect = format.pixelAspect() instance.data.update({ "subset": subset, "asset": os.environ["AVALON_ASSET"], "label": node.name(), "name": node.name(), "subset": subset, "family": family, "families": families, "avalonKnob": avalon_knob_data, "publish": node.knob('publish').value(), "step": 1, "fps": nuke.root()['fps'].value(), "resolutionWidth": resolution_width, "resolutionHeight": resolution_height, "pixelAspect": pixel_aspect, }) self.log.info("collected instance: {}".format(instance.data)) instances.append(instance) context.data["instances"] = instances self.log.debug("context: {}".format(context))
def process(self, context): asset_data = io.find_one({ "type": "asset", "name": api.Session["AVALON_ASSET"] }) self.log.debug("asset_data: {}".format(asset_data["data"])) instances = [] # creating instances per write node self.log.debug("nuke.allNodes(): {}".format(nuke.allNodes())) for node in nuke.allNodes(): try: if node["disable"].value(): continue except Exception as E: self.log.warning(E) continue # get data from avalon knob self.log.debug("node[name]: {}".format(node['name'].value())) avalon_knob_data = get_avalon_knob_data(node) self.log.debug("avalon_knob_data: {}".format(avalon_knob_data)) if not avalon_knob_data: continue if avalon_knob_data["id"] != "pyblish.avalon.instance": continue subset = avalon_knob_data.get("subset", None) or node["name"].value() # Create instance instance = context.create_instance(subset) instance.append(node) # Add all nodes in group instances. if node.Class() == "Group": node.begin() for i in nuke.allNodes(): instance.append(i) node.end() family = avalon_knob_data["families"] if node["render"].value(): self.log.info("flagged for render") family = "render.local" # dealing with local/farm rendering if node["render_farm"].value(): self.log.info("adding render farm family") family = "render.farm" instance.data['transfer'] = False instance.data.update({ "subset": subset, "asset": os.environ["AVALON_ASSET"], "label": node.name(), "name": node.name(), "subset": subset, "family": avalon_knob_data["family"], "families": [avalon_knob_data["family"], family], "avalonKnob": avalon_knob_data, "publish": node.knob('publish').value(), "step": 1, "fps": nuke.root()['fps'].value() }) self.log.info("collected instance: {}".format(instance.data)) instances.append(instance) context.data["instances"] = instances self.log.debug("context: {}".format(context))
def load(self, context, name, namespace, data): from avalon.nuke import containerise # for k, v in context.items(): # log.info("key: `{}`, value: {}\n".format(k, v)) version = context['version'] version_data = version.get("data", {}) vname = version.get("name", None) first = version_data.get("frameStart", None) last = version_data.get("frameEnd", None) # Fallback to asset name when namespace is None if namespace is None: namespace = context['asset']['name'] file = self.fname.replace("\\", "/") self.log.info("file: {}\n".format(self.fname)) precomp_name = context["representation"]["context"]["subset"] self.log.info("versionData: {}\n".format(context["version"]["data"])) # add additional metadata from the version to imprint to Avalon knob add_keys = [ "frameStart", "frameEnd", "handleStart", "handleEnd", "source", "author", "fps" ] data_imprint = { "startingFrame": first, "frameStart": first, "frameEnd": last, "version": vname } for k in add_keys: data_imprint.update({k: context["version"]['data'][k]}) data_imprint.update({"objectName": precomp_name}) # group context is set to precomp, so back up one level. nuke.endGroup() # P = nuke.nodes.LiveGroup("file {}".format(file)) P = nuke.createNode("Precomp", "file {}".format(file)) # Set colorspace defined in version data colorspace = context["version"]["data"].get("colorspace", None) self.log.info("colorspace: {}\n".format(colorspace)) # ['version', 'file', 'reading', 'output', 'useOutput'] P["name"].setValue("{}_{}".format(name, namespace)) P["useOutput"].setValue(True) with P: # iterate trough all nodes in group node and find pype writes writes = [ n.name() for n in nuke.allNodes() if n.Class() == "Group" if get_avalon_knob_data(n) ] # create panel for selecting output panel_choices = " ".join(writes) panel_label = "Select write node for output" p = nuke.Panel("Select Write Node") p.addEnumerationPulldown(panel_label, panel_choices) p.show() P["output"].setValue(p.value(panel_label)) P["tile_color"].setValue(0xff0ff0ff) return containerise(node=P, name=name, namespace=namespace, context=context, loader=self.__class__.__name__, data=data_imprint)
def process(self, context): root = nuke.root() knob_data = get_avalon_knob_data(root) add_publish_knob(root) family = "workfile" # creating instances per write node file_path = context.data["currentFile"] staging_dir = os.path.dirname(file_path) base_name = os.path.basename(file_path) subset = "{0}_{1}".format(os.getenv("AVALON_TASK", None), family) # get version string version = pype.get_version_from_path(base_name) # Get frame range first_frame = int(root["first_frame"].getValue()) last_frame = int(root["last_frame"].getValue()) handle_start = int(knob_data.get("handleStart", 0)) handle_end = int(knob_data.get("handleEnd", 0)) # Get format format = root['format'].value() resolution_width = format.width() resolution_height = format.height() pixel_aspect = format.pixelAspect() # Create instance instance = context.create_instance(subset) instance.add(root) script_data = { "asset": os.getenv("AVALON_ASSET", None), "version": version, "frameStart": first_frame + handle_start, "frameEnd": last_frame - handle_end, "resolutionWidth": resolution_width, "resolutionHeight": resolution_height, "pixelAspect": pixel_aspect, # backward compatibility "handles": handle_start, "handleStart": handle_start, "handleEnd": handle_end, "step": 1, "fps": root['fps'].value(), } context.data.update(script_data) # creating instance data instance.data.update({ "subset": subset, "label": base_name, "name": base_name, "publish": root.knob('publish').value(), "family": family, "families": [family], "representations": list() }) # adding basic script data instance.data.update(script_data) # creating representation representation = { 'name': 'nk', 'ext': 'nk', 'files': base_name, "stagingDir": staging_dir, } instance.data["representations"].append(representation) self.log.info('Publishing script version') context.data["instances"].append(instance)