# Copyright (c) 2013 Shotgun Software Inc. # # CONFIDENTIAL AND PROPRIETARY # # This work is provided "AS IS" and subject to the Shotgun Pipeline Toolkit # Source Code License included in this distribution package. See LICENSE. # By accessing, using, copying or modifying this work you indicate your # agreement to the Shotgun Pipeline Toolkit Source Code License. All rights # not expressly granted therein are reserved by Shotgun Software Inc. from tank import Hook import os import sgtk __author__ = "Diego Garcia Huerta" __contact__ = "https://www.linkedin.com/in/diegogh/" class BreakdownSceneOperations(Hook): """ Breakdown operations for Harmony. This implementation handles detection of harmony file geometric, alembic, usd and texture nodes. """ def scan_scene(self): """ The scan scene method is executed once at startup and its purpose is to analyze the current scene and return a list of references that are to be potentially operated on. The return data structure is a list of dictionaries. Each scene reference that is returned should be represented by a dictionary with three keys: - "attr": The filename attribute of the 'node' that is to be operated on. Most DCCs have a concept of a node, attribute, path or some other way to address a particular object in the scene. - "type": The object type that this is. This is later passed to the update method so that it knows how to handle the object. - "path": Path on disk to the referenced object. Toolkit will scan the list of items, see if any of the objects matches any templates and try to determine if there is a more recent version available. Any such versions are then displayed in the UI as out of date. """ app = self.parent engine = sgtk.platform.current_engine() dcc_app = engine.app attr_name = "meta.shotgun.path" refs = [] read_nodes = dcc_app.get_nodes_of_type(["READ"]) or [] for read_node in read_nodes: ref_path = dcc_app.get_node_metadata(read_node, attr_name) if ref_path: ref_path = sgtk.util.shotgun_path.ShotgunPath.from_current_os_path( ref_path ) refs.append( { "attr": attr_name, "type": "file", "path": ref_path.current_os, "node": read_node, } ) engine.log_debug("Found: %s" % refs) audio_columns = dcc_app.get_columns_of_type("SOUND") or [] for audio_column in audio_columns: audio_metadata_name = audio_column + "." + attr_name ref_path = dcc_app.get_scene_metadata(audio_metadata_name) if ref_path: ref_path = sgtk.util.shotgun_path.ShotgunPath.from_current_os_path( ref_path ) refs.append( { "attr": "SOUND", "type": "file", "path": ref_path.current_os, "node": audio_column, } ) return refs def update(self, items): """ Perform replacements given a number of scene items passed from the app. Once a selection has been performed in the main UI and the user clicks the update button, this method is called. The items parameter is a list of dictionaries on the same form as was generated by the scan_scene hook above. The path key now holds the that each attribute should be updated *to* rather than the current path. """ engine = self.parent.engine for i in items: attr = i["node"] node_type = i["type"] new_path = i["path"] if node_type == "file": # Not Implemented pass if items: engine.show_busy( "tk-multi-breakdown", "Updating functionality has not been implemented yet.", )