def _import_clip(self, path, sg_publish_data):
        """
        Imports the given publish data into Nuke Studio or Hiero as a clip.

        :param str path: Path to the file(s) to import.
        :param dict sg_publish_data: Shotgun data dictionary with all of the standard publish
            fields.
        """
        if (
            not self.parent.engine.studio_enabled
            and not self.parent.engine.hiero_enabled
        ):
            raise Exception(
                "Importing shot clips is only supported in Hiero and Nuke Studio."
            )

        import hiero
        from hiero.core import (
            BinItem,
            MediaSource,
            Clip,
        )

        if not hiero.core.projects():
            raise Exception("An active project must exist to import clips into.")

        project = hiero.core.projects()[-1]
        bins = project.clipsBin().bins()
        media_source = MediaSource(path)
        clip = Clip(media_source)
        project.clipsBin().addItem(BinItem(clip))
Beispiel #2
0
    def sequence_to_bin_item(self, seq):
        """sequence_to_bin_item will make an Sequence as bin item

        Arguments:
            seq {Dict} -- Sequence

        Returns:
            Dict -- Hiero Bin Item
        """
        return BinItem(seq)
    def _import_img_seq(self, path, sg_publish_data):
        """
        Imports the given publish data into Nuke Studio or Hiero as a clip.

        :param str path: Path to the file(s) to import.
        :param dict sg_publish_data: Shotgun data dictionary with all of the standard publish
            fields.
        """
        if not self.parent.engine.studio_enabled and not self.parent.engine.hiero_enabled:
            raise Exception(
                "Importing shot clips is only supported in Hiero and Nuke Studio."
            )

        if not hiero.core.projects():
            raise Exception(
                "An active project must exist to import clips into.")

        # get pipeline step from path
        template = self.parent.sgtk.template_from_path(path)
        fields = template.get_fields(path)
        department = str(fields["Step"])

        # set department bin
        project = hiero.core.projects()[-1]
        bins = project.clipsBin().bins()

        bin_exists = False
        for i, bin in enumerate(bins):
            if department == bin.name():
                print "%s already exists" % department
                bin_exists = True
                department_bin = bins[i]
                break

        if not bin_exists:
            department_bin = Bin(department)
            project.clipsBin().addItem(department_bin)
            print "%s added." % department_bin.name()

        # add clip to bin
        media_source = MediaSource(path)
        items = findItemsInBin(department_bin)
        for i, item in enumerate(items):
            print "item.name()", item.name()
            if item.name() in media_source.filename():
                print "%s already exists." % item.name()
                return

        clip = Clip(media_source)
        department_bin.addItem(BinItem(clip))
        print "%s added." % clip.name()
Beispiel #4
0
 def _import_shot(self, path, sg_publish_data):
     import hiero.core
     from hiero.core import newProject
     from hiero.core import BinItem
     from hiero.core import MediaSource
     from hiero.core import Clip
     from hiero.core import Sequence
     from hiero.core import VideoTrack
     import os.path
     import sys
     prj = hiero.core.projects()[-1]
     root = prj.clipsBin()
     bins = root.bins()
     clipsBin = prj.clipsBin()
     source1 = MediaSource(path)
     clip1 = Clip(source1)
     clipsBin.addItem(BinItem(clip1))
Beispiel #5
0
    def _import_img_mov(self, path, sg_publish_data):
        """
        Imports the given publish data into Nuke Studio or Hiero as a clip.

        :param str path: Path to the file(s) to import.
        :param dict sg_publish_data: Shotgun data dictionary with all of the standard publish
            fields.
        """
        if not self.parent.engine.studio_enabled and not self.parent.engine.hiero_enabled:
            raise Exception("Importing shot clips is only supported in Hiero and Nuke Studio.")

        if not hiero.core.projects():
            raise Exception("An active project must exist to import clips into.")

        # get pipeline step from path
        template = self.parent.sgtk.template_from_path(path)
        fields = template.get_fields(path)
        department = str(fields["Step"])

        # get project dict from path
        project = self.parent.sgtk.context_from_path(path).project

        # get version code from publish data
        version_code = sg_publish_data['version']['name']

        # query 'sg_path_to_movie'
        version_filters = [
            ["project", "is", project],
            ["code", "is", version_code],
            ["sg_path_to_movie", "is_not", ""]
        ]
        version_fields = ["sg_path_to_movie"]

        result = self.parent.sgtk.shotgun.find_one("Version", version_filters, version_fields)
        movie_path = result['sg_path_to_movie']

        # set department bin
        project = hiero.core.projects()[-1]
        bins = project.clipsBin().bins()

        bin_exists = False
        for i, bin in enumerate(bins):
            if department == bin.name():
                self.parent.logger.info( "%s already exists" % department)
                bin_exists = True
                department_bin = bins[i]
                break

        if not bin_exists:
            department_bin = Bin(department)
            project.clipsBin().addItem(department_bin)
            self.parent.logger.info("%s added." % department_bin.name())

        # add clip to bin
        media_source = MediaSource(movie_path)
        items = findItemsInBin(department_bin)
        for i, item in enumerate(items):
            print "item.name()", item.name()
            if item.name() in media_source.filename():
                self.parent.logger.info("%s already exists." % item.name())
                return

        clip = Clip(media_source)
        department_bin.addItem(BinItem(clip))
        self.parent.logger.info("%s added." % clip.name())