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()
def get_project_bin(self, project_bin, bin_name): """get_project_bin will try to reuse a bin from a project depending on the bin_name or will create it Arguments: project_bin {Dict} -- Project Bin bin_name {str} -- Bin's name to find Returns: Dict -- Hiero Project Bin """ b = project_bin.bins(bin_name) if len(b) > 0: b = b[0] return b, True return Bin(bin_name), False
def get_seq_bin(self, host_b, bin_name): """get_seq_bin will try to reuse a bin from a project depending on the bin_name or will create it Arguments: host_b {Dict} -- Host Bin bin_name {[type]} -- Bin's name to find Returns: Dict -- Hiero Bin """ b = host_b.bins() for seq_bin in b: if seq_bin.name() == bin_name: return seq_bin, True return Bin(bin_name), False
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())