Tk-multi-breakdown : trying to get some publish fields in the hook_scene_operations hook


We are using the breakdown2 app.

I use a custom hook_scene_operations hook. Inside this hook, I would like to retrieve some information about the new versions of the items. I would like to retrieve the value of some publish field on the new item.

I added the ‘published_file_fields’ to this app config :
  hook_scene_operations: "{config}/tk-multi-breakdown2/"
  published_file_fields: ["sg_audio_frame_start", "name", "code"]

But I don’t see how to retrieve this info in the scene operations hook. I printed the contents of the “item” dict. It has the usual things, like :

{'node_name': 'AudioRead1', 'node_type': 'AudioRead', 'path': 'some path', 'extra_data': {'old_path': 'some old path'}}

I was expecting to get the values of the publish fields in that dict

How should I proceed to retrieve that information inside this hook ?


Hi donat!

So the item you are referring to is a FileItem object. These items represent the objects in your scene. The item’s sg_data property is the ShotGrid published file data related to the scene object, which is where you can retrieve the information you are looking for. The published_file_fields app config setting is a list of published file fields that will be used to retrieve the sg_data, so any fields you include in this list will be included in the sg_data.

An example of how you can retrieve the published file field data from a hook can be found in this hook, or below is a very basic example:

    def get_published_file_info_example(self, item):
        # item is a FileItem object
        name = item.sg_data["name"]

In the example above, we are simply accessing the published file data using item.sg_data["field_name"], so for your specific published_file_fields listed above, you could also get the audio frame start data using item.sg_data["sg_audio_frame_start"].

The default published file fields that will be fetched are listed here – these fields do not need to be added to your app config setting, they will always be included in the sg_data (you do not need to include “name” in your settings).

Hope that helps!

1 Like