예제 #1
0
    def process(self):
        from nukescripts import autoBackdrop
        nodes = list()
        if (self.options or {}).get("useSelection"):
            nodes = self.nodes

            if len(nodes) >= 1:
                anlib.select_nodes(nodes)
                bckd_node = autoBackdrop()
                bckd_node["name"].setValue("{}_BDN".format(self.name))
                bckd_node["tile_color"].setValue(int(self.node_color, 16))
                bckd_node["note_font_size"].setValue(24)
                bckd_node["label"].setValue("[{}]".format(self.name))
                # add avalon knobs
                instance = anlib.imprint(bckd_node, self.data)

                return instance
            else:
                msg = str("Please select nodes you "
                          "wish to add to a container")
                self.log.error(msg)
                nuke.message(msg)
                return
        else:
            bckd_node = autoBackdrop()
            bckd_node["name"].setValue("{}_BDN".format(self.name))
            bckd_node["tile_color"].setValue(int(self.node_color, 16))
            bckd_node["note_font_size"].setValue(24)
            bckd_node["label"].setValue("[{}]".format(self.name))
            # add avalon knobs
            instance = anlib.imprint(bckd_node, self.data)

            return instance
예제 #2
0
    def reset_frame_range_handles(self):
        """Set frame range to current asset"""

        if "data" not in self._asset_entity:
            msg = "Asset {} don't have set any 'data'".format(self._asset)
            log.warning(msg)
            nuke.message(msg)
            return
        data = self._asset_entity["data"]

        missing_cols = []
        check_cols = [
            "fps", "frameStart", "frameEnd", "handleStart", "handleEnd"
        ]

        for col in check_cols:
            if col not in data:
                missing_cols.append(col)

        if len(missing_cols) > 0:
            missing = ", ".join(missing_cols)
            msg = "'{}' are not set for asset '{}'!".format(
                missing, self._asset)
            log.warning(msg)
            nuke.message(msg)
            return

        # get handles values
        handle_start = data["handleStart"]
        handle_end = data["handleEnd"]

        fps = data["fps"]
        frame_start = int(data["frameStart"]) - handle_start
        frame_end = int(data["frameEnd"]) + handle_end

        self._root_node["fps"].setValue(fps)
        self._root_node["first_frame"].setValue(frame_start)
        self._root_node["last_frame"].setValue(frame_end)

        # setting active viewers
        try:
            nuke.frame(int(data["frameStart"]))
        except Exception as e:
            log.warning("no viewer in scene: `{}`".format(e))

        range = '{0}-{1}'.format(int(data["frameStart"]),
                                 int(data["frameEnd"]))

        for node in nuke.allNodes(filter="Viewer"):
            node['frame_range'].setValue(range)
            node['frame_range_lock'].setValue(True)
            node['frame_range'].setValue(range)
            node['frame_range_lock'].setValue(True)

        # adding handle_start/end to root avalon knob
        if not avalon.nuke.imprint(self._root_node, {
                "handleStart": int(handle_start),
                "handleEnd": int(handle_end)
        }):
            log.warning("Cannot set Avalon knob to Root node!")
예제 #3
0
    def process(self):
        if (self.options or {}).get("useSelection"):
            nodes = self.nodes
            self.log.info(len(nodes))
            if len(nodes) == 1:
                anlib.select_nodes(nodes)
                node = nodes[-1]
                # check if Group node
                if node.Class() in "Group":
                    node["name"].setValue("{}_GZM".format(self.name))
                    node["tile_color"].setValue(int(self.node_color, 16))
                    return anlib.imprint(node, self.data)
                else:
                    msg = ("Please select a group node "
                           "you wish to publish as the gizmo")
                    self.log.error(msg)
                    nuke.message(msg)

            if len(nodes) >= 2:
                anlib.select_nodes(nodes)
                nuke.makeGroup()
                gizmo_node = nuke.selectedNode()
                gizmo_node["name"].setValue("{}_GZM".format(self.name))
                gizmo_node["tile_color"].setValue(int(self.node_color, 16))

                # add sticky node wit guide
                with gizmo_node:
                    sticky = nuke.createNode("StickyNote")
                    sticky["label"].setValue(
                        "Add following:\n- set Input"
                        " nodes\n- set one Output1\n"
                        "- create User knobs on the group")

                # add avalon knobs
                return anlib.imprint(gizmo_node, self.data)

            else:
                msg = ("Please select nodes you " "wish to add to the gizmo")
                self.log.error(msg)
                nuke.message(msg)
                return
        else:
            with anlib.maintained_selection():
                gizmo_node = nuke.createNode("Group")
                gizmo_node["name"].setValue("{}_GZM".format(self.name))
                gizmo_node["tile_color"].setValue(int(self.node_color, 16))

                # add sticky node wit guide
                with gizmo_node:
                    sticky = nuke.createNode("StickyNote")
                    sticky["label"].setValue(
                        "Add following:\n- add Input"
                        " nodes\n- add one Output1\n"
                        "- create User knobs on the group")

                # add avalon knobs
                return anlib.imprint(gizmo_node, self.data)
예제 #4
0
    def process(self):
        self.name = self.data["subset"]

        nodes = nuke.selectedNodes()

        if not nodes or len(nodes) == 0:
            nuke.message('Please select Read node')
        else:
            count_reads = 0
            for node in nodes:
                if node.Class() != 'Read':
                    continue
                name = node["name"].value()
                avalon_data = self.data
                avalon_data['subset'] = "{}_{}".format(self.family, name)
                self.change_read_node(self.data["subset"], node, avalon_data)
                count_reads += 1

            if count_reads < 1:
                nuke.message('Please select Read node')
        return
예제 #5
0
    def process(self):
        self.name = self.data["subset"]
        nodes = self.nodes

        if not nodes or len(nodes) == 0:
            msg = "Please select Read node"
            self.log.error(msg)
            nuke.message(msg)
        else:
            count_reads = 0
            for node in nodes:
                if node.Class() != 'Read':
                    continue
                avalon_data = self.data
                avalon_data['subset'] = "{}".format(self.name)
                self.change_read_node(self.data["subset"], node, avalon_data)
                count_reads += 1

            if count_reads < 1:
                msg = "Please select Read node"
                self.log.error(msg)
                nuke.message(msg)
        return
예제 #6
0
    def process(self):
        self.name = self.data["subset"]
        nodes = self.nodes

        if not nodes or len(nodes) == 0:
            msg = "Please select Read node"
            self.log.error(msg)
            nuke.message(msg)
        else:
            count_reads = 0
            for node in nodes:
                if node.Class() != 'Read':
                    continue
                avalon_data = self.data
                avalon_data['subset'] = "{}".format(self.name)
                avalon.nuke.lib.set_avalon_knob_data(node, avalon_data)
                node['tile_color'].setValue(16744935)
                count_reads += 1

            if count_reads < 1:
                msg = "Please select Read node"
                self.log.error(msg)
                nuke.message(msg)
        return